Ateev Chopra
Ateev Chopra

Reputation: 1026

Installing dev dependencies in Google Cloud App Engine

I'm trying to deploy my React app to the Google Cloud App Engine. I've added a app.yaml file too. It Looks like this:

// app.yaml    
runtime: nodejs
env: flex

Now, I want to build my project using webpack before deployment. So following the docs, I've added prestart script to the package.json. Now my scripts portion of package.json looks like this:

  "scripts": {
    "build": "npm-run-all --parallel webpack-client-build webpack-server-build",
    "webpack-server-build": "NODE_ENV='development' webpack --config ./webpack/webpack.server.config.js --progress --colors --watch",
    "webpack-client-build": "NODE_ENV='development' webpack --config ./webpack/webpack.browser.config.js --progress --colors --watch",
    "build-prod": "npm-run-all webpack-client-build-prod webpack-server-build-prod",
    "webpack-server-build-prod": "webpack --config ./webpack/webpack.server.config.js -p",
    "webpack-client-build-prod": "webpack --config ./webpack/webpack.browser.config.js -p",
    "prestart": "npm run build-prod",
    "start": "pm2 start dist/main.js"
  },

I'm using npm-run-all to build both server side and client side pacakges. But because of this, my build is failing as in docs it says

Note: Webpack must be listed in the dependencies of the package.json file, as by default devDependencies are not installed when the app is deployed to Google App Engine.

How can I install the node dev dependencies for deployment of my Node app in the Google Cloud ?

Thanks :)

Upvotes: 3

Views: 1998

Answers (1)

CWSites
CWSites

Reputation: 1801

When Google Cloud spins up an app it runs npm install however it only has access to dependencies and not devDependencies.

Try moving webpack into the dependencies portion of package.json.

Upvotes: 3

Related Questions