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

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 )

Andrew H
  • 51
  • 1
  • 5

3 Answers3

3

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 .
WaLid LamRaoui
  • 2,305
  • 2
  • 15
  • 33
  • 1
    Thank you for the response, although it still doesn't work, I'm assuming its just another simple typo that I'll have to figure out. – Andrew H Nov 08 '19 at 05:05
  • 1
    sorry i forgot that you need to delete node_modules in root directory as well in client directory since it was pushed to the repo before and it must not be there , i edited the answer , so basically that's what i noticed first and i thought it was the reason, however it could be something else , when you manage to fix the error plz consider to post how you did it . – WaLid LamRaoui Nov 08 '19 at 08:35
  • 1
    I finally deployed successfully, thank you for your help. There wasn't another typo, I was having odd issues associated with my monogURI. The solution was to install mLab MongoDB in resources as a free add-on, copy the monogdb_uri from settings under "reveal config vars", and paste the new monogURI into my production.json file. – Andrew H Nov 12 '19 at 07:57
3

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.

Geno Chen
  • 4,916
  • 6
  • 21
  • 39
-1

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

adithan bs
  • 41
  • 3