尝试在elastic beanstalk上启动react节点应用程序,但遇到服务器端错误
我的文件夹设置为
-client
-server
- index.js
- other files etc
-package.json在我的package.json中,我的脚本如下所示
{
"version": "0.0.0",
"main": "dist/index.js",
"scripts": {
"clean": "rm -rf build && mkdir build",
"build-server": "babel -d ./build ./server -s",
"build": "npm run clean && npm run build-server",
"start": "npm run build && node ./build/index.js",
},
"dependencies": {
"@babel/runtime": "^7.9.2",
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/node": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.2",
"babel-loader": "^8.0.6",
"nodemon": "^2.0.7"
}
}运行eb deploy时,我收到错误
Jan 28 04:51:45 web: > api@0.0.0 start /var/app/current
Jan 28 04:51:45 web: > npm run build && node ./build/index.js
Jan 28 04:51:45 web: > api@0.0.0 build /var/app/current
Jan 28 04:51:45 web: > npm run clean && npm run build-server
Jan 28 04:51:45 web: > api@0.0.0 clean /var/app/current
Jan 28 04:51:45 web: > rm -rf build && mkdir build
Jan 28 04:51:45 web: > api@0.0.0 build-server /var/app/current
Jan 28 04:51:45 web: > babel -d ./build ./server -s
Jan 28 04:51:45 web: sh: babel: command not found不确定如何修复这个问题,因为我的package.json已经包含了babel依赖项
此外,在其他在线教程中,我看到一些指南指出要将index.js作为编译文件输出,并包含一个Procfile,它覆盖npm start并运行编译文件,但这种方法对我不起作用,因为我的服务器包含10+文件。
"babel index.js --out-file index-compiled.js",感谢您的帮助。谢谢
发布于 2021-01-30 04:26:08
必须设置aws环境变量
NPM_USE_PRODUCTION = false
安装dev依赖项
https://stackoverflow.com/questions/65931252
复制相似问题