我正在尝试将我的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应用程序?
谢谢:)
答案 0 :(得分:0)
当Google云移动应用时,它会运行npm install
,但只能访问dependencies
而非devDependencies
。
尝试将webpack
移至dependencies
的{{1}}部分。