Andrew H
Andrew H

Reputation: 51

Heroku Build Fail [sh: 1: react-scripts: Permission denied]

    ----> 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

       > [email protected] 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

       > [email protected] 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

       > [email protected] build /tmp/build_33db88ab97938128199a401d17366aac/client
       > react-scripts build

sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the [email protected] 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! [email protected] 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 [email protected] 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

Synopsis:

I recently finished MERN stack course and went to go push my build to Heroku but encountered the error above. I first thought it was a visual studio permissions error so I ran vs code with elevated privileges. This, however, did not work.

I've tried and had no success with:

  1. Adding a nodejs script build package to my deployment
  2. Modifying my package.json to incorporate engine which selects the version of node.js to run
  3. Adding .js extensions to the end of the server in the scripts section thinking there may be a simple issue with that
  4. Double checking that my local instance works properly (it does)
  5. Promptly throwing my computer out my window (feels pretty good, but still not working)

Refer to this link to see how to check your file for the correct permissions and how to set them ( Updating file permissions with git-bash on Windows 7 )

Upvotes: 4

Views: 6585

Answers (3)

adithan bs
adithan bs

Reputation: 41

check your package.json => React-script-->

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

Ex: "react-scripts": "1.0.1" change ==>"react-scripts": "3.4.3"

step = 2==> install ==> npm i

step = 3 ==> npm start

Upvotes: -1

WaLid LamRaoui
WaLid LamRaoui

Reputation: 2455

I took a look at you GitHub repo and it seems to be a simple typo in your .gitignore file :

node_module/ config/default.json

And this should be :

node_modules/ config/default.json

Notice the name of node_modules folder ,so a quick fix would be to edit you .gitignore file and put the wright name , then run the following :

  • git rm -r --cached node_modules
  • delete node_modules in root directory as well in client/
  • git commit -am 'ignore node_modules' And finally push your changes , this should fix the error .

Upvotes: 3

Geno Chen
Geno Chen

Reputation: 5214

sh: 1: react-scripts: Permission denied

So this is a permission issue. Go to the correct path that contains a react-scripts and do a chmod +x react-scripts will solve this issue.

Upvotes: 3

Related Questions