Tôi có một ứng dụng nút js được triển khai tại elasticbeanstalk. Nút được cài đặt và symlinked, npm và webpack. Nhưng khi chạy npm run build-prod
, chính nó sẽ gọi tập lệnh webpack --config /var/app/current/webpack.prod.config.js
. Nhận được lỗi sau với trạng thái thoát -2. Điều tương tự cũng xảy ra nếu tôi chạy lệnh webpack trực tiếp. Tôi đang tìm giải pháp.AWS Elastic Beanstalk - Cách xây dựng gói JS bằng cách sử dụng npm và webpack
[2016-07-26T06:57:36.301Z] INFO [9731] - [Application update [email protected]/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_site_web/Command 06_npm_run_build_prod] : Activity execution failed, because:
> [email protected] build-prod /tmp/deployment/application
> webpack --config /var/app/current/webpack.prod.config.js
npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! [email protected] build-prod: `webpack --config /var/app/current/webpack.prod.config.js`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build-prod script 'webpack --config /var/app/current/webpack.prod.config.js'.
npm ERR! This is most likely a problem with the site-web package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack --config /var/app/current/webpack.prod.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs site-web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls site-web
npm ERR! There is likely additional logging output above.
npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/bin/npm" "run" "build-prod"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE
chứa tập tin cấu hình:
container_commands:
01_node_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
02_npm_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
03_npm_install_global_packages:
command: "npm install webpack webpack-cli -g"
04_webpack_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/webpack /bin/webpack"
#05_webpack_run_build_prod:
#command: "webpack --config /var/app/current/webpack.prod.config.js --progress --colors"
06_npm_run_build_prod:
command: "npm run build-prod"
Scripts trong package.json
"scripts": {
"build": "webpack --config webpack.local.config.js --progress --colors",
"build-local": "webpack --config webpack.prod.config.js --progress --colors",
"build-prod": "webpack --config /var/app/current/webpack.prod.config.js",
"server": "node app.js",
"dev-server": "node dev-app.js"
}
Và khi tôi bỏ ghi chú 05 được chạy lệnh webpack trực tiếp nó kết thúc với lỗi Error: "/var/app/current/site-web/static/assets/app/index.js" is not in the SourceMap.
Tập lệnh xây dựng thành công tại địa phương nhưng bị chặn trên tất cả các cách sản xuất. Không thể tìm ra cách chạy lệnh webpack để xây dựng JS trên môi trường bean bean AWS. Không phải là cách lý tưởng để xây dựng tệp JS?
nút: 4.4.6 NPM: 2.15.5 webpack: mới nhất
Có thể là/var/app/hiện tại/webpack Tệp .prod.config.js bị thiếu? –
Nó ở đó. Tôi sử dụng 'eb deploy' để triển khai mã và ssh để kiểm tra xem tệp ở đó và kịch bản lệnh xây dựng có thể được chạy thủ công hay không. – Babu