webpack - ElasticBeanstalk - 容器命令 Webpack 构建错误
问题描述
我正在尝试将我的 webpack 构建命令从必须在推送到存储库并部署到我的服务器之前运行迁移到让 elasticbeanstalk 扩展运行容器命令。我认为只需添加一个 eb 扩展程序npm run build
就可以生成这个,而不会像在本地环境中那样出现任何问题,但是我收到以下错误:
Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by:
> app@0.5.0 build /tmp/deployment/application
> webpack
npm ERR! Linux 4.14.47-56.37.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/node" "/bin/npm" "run" "build"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! app@0.5.0 build: `webpack`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the app@0.5.0 build script 'webpack'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls app
npm ERR! There is likely additional logging output above.
npm ERR! Linux 4.14.47-56.37.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.14.3-linux-x64/bin/node" "/bin/npm" "run" "build"
npm ERR! node v6.14.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
这是弹性beantalk配置文件:
container_commands:
00_npm_build:
command: "sudo npm run build"
config.json 脚本部分:
"main": "app.js",
"scripts": {
"start": "node app.js",
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"sql": "./node_modules/sequelize-cli/lib/sequelize",
"sql:migrate": "npm run sql db:migrate"
},
和 webpack 配置:
module.exports = {
entry: "./public/index.js",
output: {
path: __dirname + "/dist",
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
};
解决方案
这些都不起作用,我只是做了:
-在 EBS 配置中,我将Node 命令设置为 npm start
-在 package.json 中:
"scripts": {
...
"start": "npx sequelize-cli db:migrate && node index.js"
},
推荐阅读
- python - Python - ValueError:找到包含 0 个样本的数组(缩放函数)
- swift - SwiftUI CoreData:在视图加载时将 CoreData 元素附加到数组中(或者有更好的方法吗?)
- sql - 聚合在单个列上,但其中的一个值除外
- sql - 合并 2 个 SQL Server 查询
- javascript - 如何一次在powershell中运行多个javascript(nodejs)文件?
- r - 登录后下载 CSV 文件
- python - 多个.cpp文件共享的Boost / Python全局字符串变量导致未定义的符号错误
- java - 在android studio中上传图像后如何将图像URL插入firestore数据库?
- debugging - 从 c 中的 popen() 创建的文件描述符读取时出现段错误
- javascript - 使用 Javascript 将大数据文件上传到 OneDrive