在Google Cloud App Engine中安装dev依赖项

时间:2017-08-14 05:02:49

标签: node.js google-app-engine webpack google-cloud-platform

我正在尝试将我的React应用部署到Google Cloud App Engine。我也添加了app.yaml文件。它看起来像这样:

// app.yaml    
runtime: nodejs
env: flex

现在,我想在部署之前使用webpack构建我的项目。因此,在docs之后,我已将prestart脚本添加到package.json。现在我的package.json的脚本部分如下所示:

  "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"
  },

我正在使用npm-run-all来构建服务器端和客户端端的pacakges。但正因为如此,我的构建失败了,就像在文档中所说的那样

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.

如何安装节点开发依赖项以在Google Cloud中部署我的Node应用程序?

谢谢:)

1 个答案:

答案 0 :(得分:0)

当Google云移动应用时,它会运行npm install,但只能访问dependencies而非devDependencies

尝试将webpack移至dependencies的{​​{1}}部分。

相关问题