代码之家  ›  专栏  ›  技术社区  ›  Zeeno

同时使用生成的React。js找不到构建命令[反应脚本:找不到命令]

  •  2
  • Zeeno  · 技术社区  · 8 年前

    我正在尝试在Elastic Beanstalk上部署一个使用express并同时在上的react应用程序,但我遇到一个错误,它找不到react scripts命令。我仔细检查了react脚本是否是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
    

    非常感谢!:-)

    2 回复  |  直到 8 年前
        1
  •  3
  •   Anatol    8 年前

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

        2
  •  3
  •   iamandrewluca    8 年前

    更新: 看来这只是 yarn npm https://github.com/npm/npm/issues/17379#issuecomment-358434577

    您可以尝试删除 node_modules package-lock.json yarn.lock
    并执行 npm install 再一次

    或者您可以降级 npm公司 4.6.1 这没有问题

    npm -g i npm@4.6.1