Heroku Build Fail [sh:1:react-scripts:权限被拒绝]

时间:2019-11-08 01:25:58

标签: javascript node.js heroku

    ----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)

       Resolving node version 12.x...
       Downloading and installing node 12.13.0...
       Using default npm version: 6.12.0

-----> Installing dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules

       > nodemon@1.19.3 postinstall /tmp/build_33db88ab97938128199a401d17366aac/node_modules/nodemon
       > node bin/postinstall || exit 0

       Love nodemon? You can now support the project via the open collective:


          > https://opencollective.com/nodemon/donate

//REMOVED INSTALLATION TEXT HERE DUE TO CHAR LIMIT


-----> Build
       Running heroku-postbuild

       > website_setup@1.0.0 heroku-postbuild /tmp/build_33db88ab97938128199a401d17366aac
       > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client

       audited 905041 packages in 14.447s
       found 1 moderate severity vulnerability
         run `npm audit fix` to fix them, or `npm audit` for details

       > client@0.1.0 build /tmp/build_33db88ab97938128199a401d17366aac/client
       > react-scripts build

sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_454Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! website_setup@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the website_setup@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.1egfD/_logs/2019-11-08T01_04_59_470Z-debug.log
-----> Build failed


       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys

       Some possible problems:

       - node_modules checked into source control
         https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

       Love,
       Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

简介:

我最近完成了MERN堆栈课程,然后继续将我的构建推送到Heroku,但是遇到了上面的错误。我首先认为这是一个Visual Studio权限错误,所以我以特权提升运行了vs代码。但是,这没有用。

我尝试过但没有成功

  1. 将nodejs脚本构建包添加到我的部署中
  2. 修改我的package.json以合并选择要运行的node.js版本的引擎
  3. 在脚本部分将.js扩展名添加到服务器的末尾,以为可能存在一个简单的问题
  4. 仔细检查我的本地实例是否可以正常工作
  5. 立即将计算机扔出我的窗户(感觉很好,但仍然无法正常工作)

请参阅此链接以了解如何检查文件的正确权限以及如何设置权限(Updating file permissions with git-bash on Windows 7

3 个答案:

答案 0 :(得分:2)

我看了看您的GitHub repo,它似乎是您的.gitignore文件中的一个简单错字:

node_module/ config/default.json

这应该是:

node_modules/ config/default.json

请注意node_modules文件夹的名称,因此一个快速解决方案是编辑您的.gitignore文件并放入wright名称,然后运行以下命令:

  • git rm -r --cached node_modules
  • delete node_modules in root directory as well in client/
  • git commit -am 'ignore node_modules' 最后推送您的更改,这应该可以修复错误。

答案 1 :(得分:1)

  

sh: 1: react-scripts: Permission denied

这是一个权限问题。转到包含react-scripts的正确路径,然后执行chmod +x react-scripts将解决此问题。

答案 2 :(得分:-1)

检查你的 package.json => React-script-->

step = 1==> "react-scripts": "(change_currend_version)"

例如:"react-scripts": "1.0.1" 更改 ==>"react-scripts": "3.4.3"

step = 2==> 安装 ==> npm i

step = 3 ==> npm start