【问题标题】:React built with concurrently.js not finding build command [react-scripts: command not found]使用 concurrently.js 构建的 React 没有找到构建命令 [react-scripts: command not found]
【发布时间】:2018-06-14 11:31:17
【问题描述】:

我正在尝试在 Elastic Beanstalk 上部署一个使用 express 和并发的 react 应用程序,但是我收到一个错误,它找不到 react-scripts 命令。我已经仔细检查过 react-scripts 是 json 中的一个依赖项(它是由 react 自动生成的),所以我不太确定为什么它仍然无法找到它。

下面是日志

-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
[0] 
[0] > project-deztructicus@0.1.0 server-live /var/app/current
[0] > node server.js
[0] 
[0] Server started on port 5000
[1] 
[1] > client@0.1.0 start /var/app/current/client
[1] > react-scripts start
[1] 
[1] sh: react-scripts: command not found
[1] npm ERR! file sh
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno ENOENT
[1] npm ERR! syscall spawn
[1] npm ERR! client@0.1.0 start: `react-scripts start`
[1] npm ERR! spawn ENOENT
[1] npm ERR! 
[1] npm ERR! Failed at the client@0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] npm WARN Local package.json exists, but node_modules missing, did you mean to install?
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! project-deztructicus@0.1.0 client: `npm start --prefix client`
[1] npm ERR! Exit status 1
[1] npm ERR! 
[1] npm ERR! Failed at the project-deztructicus@0.1.0 client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] npm run client exited with code 1

提前非常感谢! :-)

【问题讨论】:

  • 我将 package.json 设置为需要节点 12+ 和 npmp 6+,但仍然出现同样的错误。我认为这是因为它需要全局安装 react-scripts,但你没有这样做就让它工作了吗?

标签: reactjs amazon-web-services express amazon-elastic-beanstalk


【解决方案1】:

这不是create-react-app 问题,是 npm 问题。 检查此链接https://github.com/npm/npm/issues/17379

【讨论】:

  • EBS 默认使用旧版本的 NPM 和 Node.js。更新 npm 和 node 解决了这个问题。
【解决方案2】:

更新:这似乎只是yarnnpm 之间的不一致 https://github.com/npm/npm/issues/17379#issuecomment-358434577

您可以尝试删除node_modulespackage-lock.jsonyarn.lock
并再次执行npm install

或者您可以将没有问题的npm 降级为4.6.1

npm -g i npm@4.6.1

【讨论】:

    猜你喜欢
    • 2018-05-30
    • 1970-01-01
    • 2019-02-10
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    • 2022-07-09
    • 2020-03-20
    • 2013-08-11
    相关资源
    最近更新 更多