首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS Elastic Beanstalkl Nodejs React部署错误babel:未找到命令

AWS Elastic Beanstalkl Nodejs React部署错误babel:未找到命令
EN

Stack Overflow用户
提问于 2021-01-28 13:00:36
回答 1查看 218关注 0票数 1

尝试在elastic beanstalk上启动react节点应用程序,但遇到服务器端错误

我的文件夹设置为

代码语言:javascript
复制
-client
-server
  - index.js
  - other files etc
-package.json

在我的package.json中,我的脚本如下所示

代码语言:javascript
复制
{

  "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时,我收到错误

代码语言:javascript
复制
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+文件。

代码语言:javascript
复制
"babel index.js --out-file index-compiled.js",

感谢您的帮助。谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-30 04:26:08

必须设置aws环境变量

NPM_USE_PRODUCTION = false

安装dev依赖项

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65931252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档