Heroku engines.node (package.json) unspecified - node.js

I'm having a problem with pushing my codes to Heroku.
package.json
{
"name": "my-app",
"version": "0.1.0",
"engine": {
"node": "12.16.2",
"npm": "6.13.4"
},
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"bcrypt": "^4.0.1",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.4.20",
"nodemon": "^2.0.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "node server/index.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"backend": "nodemon server/index.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
output
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.16.1...
remote: Using default npm version: 6.13.4
<!-- more stuff -->
remote: -----> Build
remote: Running build
remote:
remote: > my-app#0.1.0 build /tmp/build_016788c07037e47ee5638bf5c1b1f631
remote: > react-scripts build
remote:
remote: Could not find a required file.
remote: Name: index.html
remote: Searched in: /tmp/build_016788c07037e47ee5638bf5c1b1f631/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! my-app#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the my-app#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.yXjxR/_logs/2020-04-11T07_16_57_245Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
As you can see even though I specified my node and npm version in package.json Heroku is not recognising it and my push is rejected. I tried to make a ticket on the Heroku website but since this is a free application they did not allow me to ask on their helpline.
edit
I upgraded the npm and node version to the default by Heroku but I get the error Could not find a required file.Name: index.html

I had the same issue. Looks like Heroku doesn't support 12.16.2 yet. try with 12.16.1 in package.json engine section.
change this
"engine": {
"node": "12.16.2",
"npm": "6.13.4"
},
to
"engines": {
"node": "12.16.1",
"npm": "6.14.4"
},

For deploying your app successfully. You should first create a specific file inside the root of your project's folder and the name of that file must be.
Procfile
without any extra extension. the content of Procfile file must be web: node index.js or whatever your main file is. don't use web: node run index.js just web: node index.js is ok.

my package.json didnt have
"engines" specified
adding
"engines": { "node": "12.16.1", "npm": "6.14.4" },
in my package.json fixed it

Related

Nodejs: failed to push some refs to 'https://git.heroku.com/myproject.git'

I made a portfolio with Reactjs and a little bit of nodejs to implement nodemailer, and now I'm trying to deploy to heroku but I'm getting this error: ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git
I'm trying everthing but it seems nothing working, I did a lot of research around but nothing worked to me
Here is the error when I'm trying to push to heroku
Enumerating objects: 38099, done.
Counting objects: 100% (38099/38099), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28232/28232), done.
Writing objects: 100% (38099/38099), 98.10 MiB | 108.00 KiB/s, done.
Total 38099 (delta 8542), reused 38081 (delta 8535), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 16.15.0
remote: engines.npm (package.json): 7.24.2
remote:
remote: Resolving node version 16.15.0...
remote: Downloading and installing node 16.15.0...
remote: Bootstrapping npm 7.24.2 (replacing 8.5.5)...
remote: npm 7.24.2 installed
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json)
remote:
remote: added 89 packages, and audited 90 packages in 8s
remote:
remote: 12 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 1 critical severity vulnerability
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > myportfolio#1.0.0 heroku-postbuild
remote: > cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build
remote:
remote:
remote: up to date, audited 1466 packages in 3s
remote:
remote: 194 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 7 high severity vulnerabilities
remote:
remote: To address issues that do not require attention, run:
remote: npm audit fix
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: added 64 packages, removed 188 packages, changed 281 packages, and audited 1342 packages in 27s
remote:
remote: 207 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 6 high severity vulnerabilities
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: > frontend#0.1.0 build
remote: > react-scripts build
remote:
remote: sh: 1: react-scripts: Permission denied
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to dedaportfolio.
remote:
To https://git.heroku.com/dedaportfolio.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git'
this the package.json in the root of my project
{
"name": "myportfolio",
"version": "1.0.0",
"engines": {
"node": "16.15.0",
"npm":"7.24.2"
},
"description": "",
"main": "index.js",
"scripts": {
"client": "cd client && npm start",
"server": "nodemon server.js",
"build": "cd client && npm run build",
"dev":"concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"nodemailer": "^4.7.0"
},
"devDependencies": {
"concurrently": "^7.3.0"
}
}
This is my client package.json
{
"name": "client",
"version": "0.1.0",
"engines": {
"node": "16.15.0"
},
"private": true,
"dependencies": {
"#fortawesome/free-brands-svg-icons": "^6.1.2",
"#fortawesome/free-solid-svg-icons": "^6.1.2",
"#fortawesome/react-fontawesome": "^0.2.0",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"bootstrap": "^5.2.0",
"framer-motion": "^7.0.0",
"react": "^18.2.0",
"react-bootstrap": "^2.4.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"react-scroll": "^1.8.7",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
The final three messages here:
To https://git.heroku.com/dedaportfolio.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/dedaportfolio.git'
are from Git itself and are simply a summary of the fact that Heroku (not Git) didn't like your code. Ignore them entirely as they add no information whatsoever; pay attention only to the remote:-prefixed lines. Git relays these lines to you whenever Heroku tells you why it does not like your code.
The remaining problems are all specific to either Heroku or your code. In this case, the errors come from npm, which is noting:
high severity vulnerabilities
which you should fix because security vulnerabilities are bad, but most importantly, from the next step in the build process:
sh: 1: react-scripts: Permission denied
which simply means that your react-scripts in the stuff you're deploying is wrong, so have a look at that.

Heroku Deployment SassError: File to import not found or unreadable. Works fine locally

Attempting to deploy to heroku for the first time, and i've been getting this sasserror which causes the build to fail and reject.
Steps taken for resolution
Delete node sass and node modules / reinstall / push to master repo
Adjust import path to #import './scss/_variables.scss';
Delete the first import to check if that file was the issue
Update node to support node-sass compatibility
Question
Create React App has webpack built internally, do i need to add my own webpack config for sass-loaders, css-loaders, style-loaders?
i've only ever used webpack with rails before, if i do need webpack, for my output params, what should replace the "bundle.js" i get from rails?
Terminal response
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 10.x
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 10.x...
remote: Downloading and installing node 10.24.1...
remote: Using default npm version: 6.14.12
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: > nodemon#2.0.4 postinstall /tmp/build_f7e8f26d/node_modules/nodemon
remote: > node bin/postinstall || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 358 packages in 10.306s
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > server#1.0.0 heroku-postbuild /tmp/build_f7e8f26d
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote:
remote: > node-sass#6.0.0 install /tmp/build_f7e8f26d/client/node_modules/node-sass
remote: > node scripts/install.js
remote:
remote: Downloading binary from https://github.com/sass/node-sass/releases/download/v6.0.0/linux-x64-64_binding.node
remote: Download complete
remote: Binary saved to /tmp/build_f7e8f26d/client/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote: Caching binary to /tmp/npmcache.gWg6N/node-sass/6.0.0/linux-x64-64_binding.node
remote:
remote: > core-js#2.6.12 postinstall /tmp/build_f7e8f26d/client/node_modules/babel-runtime/node_modules/core-js
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > core-js#3.12.1 postinstall /tmp/build_f7e8f26d/client/node_modules/core-js
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > core-js-pure#3.12.1 postinstall /tmp/build_f7e8f26d/client/node_modules/core-js-pure
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > ejs#2.7.4 postinstall /tmp/build_f7e8f26d/client/node_modules/ejs
remote: > node ./postinstall.js
remote:
remote:
remote: > node-sass#6.0.0 postinstall /tmp/build_f7e8f26d/client/node_modules/node-sass
remote: > node scripts/build.js
remote:
remote: Binary found at /tmp/build_f7e8f26d/client/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote: Testing binary
remote: Binary is fine
remote: added 2124 packages from 812 contributors and audited 2131 packages in 43.95s
remote:
remote: 139 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 81 vulnerabilities (80 moderate, 1 high)
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: > client#0.1.0 build /tmp/build_f7e8f26d/client
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: ./src/App.scss
remote: SassError: File to import not found or unreadable: ./scss/_variables.scss.
remote: on line 2 of src/App.scss
remote: >> #import './scss/_variables.scss';
remote:
remote: ^
remote:
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the client#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.gWg6N/_logs/2021-05-25T08_12_53_624Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! server#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the server#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.gWg6N/_logs/2021-05-25T08_12_53_642Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
App.scss
// Abstracts
#import 'scss/variables';
#import 'scss/mixins';
// Base
#import 'scss/globals';
// Components
#import 'scss/header';
#import 'scss/showcase';
#import 'scss/hero';
#import 'scss/feature';
#import 'scss/postLanding';
#import 'scss/footer';
#import 'scss/auth';
#import 'scss/postList';
...etc
client package json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"cra-template": "1.0.3",
"moment": "^2.29.1",
"node-sass": "^6.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.1.0",
"react-moment": "^1.0.0",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"uuid": "^8.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://127.0.0.1:5000",
"secure": false,
"devDependencies": {}
}
server package json
{
"name": "server",
"version": "1.0.0",
"description": "jounii",
"main": "server.js",
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\" ",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "Andrew Huang",
"license": "MIT",
"dependencies": {
"aws-sdk": "^2.771.0",
"axios": "^0.21.1",
"bcryptjs": "^2.4.3",
"colors": "^1.4.0",
"concurrently": "^5.3.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"faker": "^5.1.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"mongoose": "^5.12.3",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"multer-s3": "^2.9.0",
"node-geocoder": "^3.27.0",
"nodemailer": "^6.6.0",
"request": "^2.88.2"
},
"devDependencies": {
"nodemon": "^2.0.4"
},
"engines": {
"node": "10.x"
}
}
File tree
enter image description here
Try this:
https://create-react-app.dev/docs/adding-a-sass-stylesheet
f you set SASS_PATH=node_modules:src, this will allow you to do imports like
#import 'styles/colors'; // assuming a styles directory under src/, where _colors.scss partial file exists.
#import 'nprogress/nprogress'; // importing a css file from the nprogress node module

MERN app fails to run "heroku-postbuild" script while being deployed to Heroku

Everything runs just fine until I try to deploy the app to the Heroku. After logging in, these are the terminal commands I run to deploy the app (and the response):
heroku login
heroku: Press any key to open up the browser to login or q to exit:
Logging in... done
Logged in as #hidden
heroku create
Creating app... done, ⬢ lower-donair-61893
https://lower-donair-61893.herokuapp.com/ | https://git.heroku.com/lower-donair-61893.git
git init
Initialized empty Git repository in #hidden
heroku git:remote -a lower-donair-61893
git add .
warning: adding embedded git repository: client
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached client
hint:
hint: See "git help submodule" for more information.
warning: LF will be replaced by CRLF in package-lock.json.
The file will have its original line endings in your working directory
git commit -am "make it better"
[master (root-commit) cdaf621] make it better
13 files changed, 2518 insertions(+)
create mode 100644 .gitignore
create mode 160000 client
create mode 100644 config/default.json
create mode 100644 models/Comment.js
create mode 100644 models/Post.js
create mode 100644 models/User.js
create mode 100644 package-lock.json
create mode 100644 package.json
create mode 100644 routes/api/auth.js
create mode 100644 routes/api/posts.js
create mode 100644 routes/api/users.js
create mode 100644 server.js
The "fun" starts when I run the last command:
git push heroku master
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 8 threads
Compressing objects: 100% (15/15), done.
Writing objects: 100% (19/19), 28.99 KiB | 1.61 MiB/s, done.
Total 19 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.18.2...
remote: Using default npm version: 6.14.5
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > nodemon#2.0.4 postinstall /tmp/build_01ff90de74651f20444f369d014096d8/node_modules/nodemon
remote: > node bin/postinstall || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 267 packages from 151 contributors and audited 268 packages in 9.402s
remote:
remote: 12 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > heroku-postbuild /tmp/build_01ff90de74651f20444f369d014096d8
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote: up to date in 0.219s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_01ff90de74651f20444f369d014096d8/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_01ff90de74651f20444f369d014096d8/client/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.0iNHH/_logs/2020-07-01T13_46_53_504Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.0iNHH/_logs/2020-07-01T13_46_53_520Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to lower-donair-61893.
remote:
To https://git.heroku.com/lower-donair-61893.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/lower-donair-61893.git'
So it's an ENOENT, yet I searched for other MERN apps being deployed to Heroku and found this vid:
https://www.youtube.com/watch?v=71wSzpLyW9k&list=PLillGF-RfqbbiTGgA77tGO426V3hRF9iE&index=8
in which he used the same lines of code as I did. Also my app is a "continue" of his series, so the file structures, scripts etc. are the exact same (that means if you navigate to the video's desc, you can see the link to the github repo, which has a lot less, but the key files such as package.json etc. are cloned).
This is the postbuild script I'm trying to run:
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
This is a screenshot of my file structure:
file structure
I've been searching for an answer for past 4 hours and found absolutely nothing. The error messages point out this path, but I can't really find it to review the full log.
/tmp/npmcache.0iNHH/_logs/2020-07-01T13_46_53_504Z-debug.log
Please, if you need to see more, tell me and I'll happily provide whatever you need - for now I'll copy all the code in both package.json files (server and client):
Server one:
{
"name": "#hidden",
"version": "1.0.0",
"description": "#hidden",
"main": "server.js",
"scripts": {
"client-install": "npm install --prefix client",
"start": "node server",
"server": "nodemon server",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"keywords": [
#hidden
],
"author": "#hidden",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"concurrently": "^5.2.0",
"config": "^3.3.1",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.19"
},
"devDependencies": {
"nodemon": "^2.0.4"
}
}
Client one:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"moment": "^2.27.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-moment": "^0.9.7",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"react-router-redux": "^4.0.8",
"react-scripts": "3.4.1",
"react-transition-group": "^4.4.1",
"reactstrap": "^8.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
I managed to solve this and successfuly deploy the app by removing all the default gitignore exceptions inside my client folder. I don't know why, but there was "/build" included. My final client gitignore file only includes:
/node_modules
if it is heroku postbuild issue then first run
npm run build
in your local system inside client folder(frontend application), it will throw an error if some dependency is missing inside your react app,
if build command is successful only then delete node_modules and package-lock.json file and then run
npm install
Check to have the correct commands in the package.json. For me I had the following setup command wrong.
"heroku-postbuild": "npm install && npm run build"
Try to read all errors because they are usually very clear and indicate exactly which command failed at which line.

Struggling to deploy my react project to heroku due to this `remote: sh: 1: react-scripts: Permission denied error`

I know that this answer has been asked in the past but I could not find a solution that pertains to my case. I've tried reinstalling my node_modules and my package-lock files, I've made sure that my .gitignore file properly excludes node_modules from the build. I'm not entirely sure what's going wrong when I try to deploy. I've been working on this for a couple of days, trying to diagnose the issue to no avail. So I figured that I'd try here. I am using a server-client setup wherein I have separate package files for my server-side code and my client-side code. Here are the package files, my gitignore file and
the error log from the heroku build session:
CLIENT PACKAGE.JSON
{
"name": "lang-flash",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000",
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"faker": "^4.1.0",
"firebase": "^7.14.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.4.1",
"stripe": "^8.39.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
SERVER PACKAGE.JSON
{
"name": "lang-flash",
"version": "1.0.0",
"engines": {
"node": "12.16.1",
"npm": "6.13.4"
},
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"client": "cd client && npm start",
"server": "nodemon server.js",
"build": "cd client && npm run build",
"dev": "concurrently --kill-other-on-fail \"npm server\" \"npm client\"",
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/7ujh6/LangFlashApp.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/7ujh6/LangFlashApp.git/issues"
},
"devDependencies": {
"concurrently": "^5.1.0",
"nodemon": "^2.0.3"
},
"homepage": "https://github.com/7ujh6/LangFlashApp.git#readme",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "8.2.0",
"express": "^4.17.1"
}
}
GIT IGNORE FILE (in the server directory there isn't another git ignore file in the client directory)
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
HEROKU BUILD LOG
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > lang-flash#1.0.0 heroku-postbuild /tmp/build_fcc986a2385b8c8783c9e93e3af2bd41
remote: > cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build
remote:
remote: audited 1748 packages in 13.332s
remote:
remote: 59 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 2 vulnerabilities (1 low, 1 high)
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote: audited 1748 packages in 11.758s
remote:
remote: 59 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 2 vulnerabilities (1 low, 1 high)
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: > lang-flash#0.1.0 build /tmp/build_fcc986a2385b8c8783c9e93e3af2bd41/client
remote: > react-scripts build
remote:
remote: sh: 1: react-scripts: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! lang-flash#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the lang-flash#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.jCutB/_logs/2020-05-14T22_31_39_955Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! lang-flash#1.0.0 heroku-postbuild: `cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the lang-flash#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.jCutB/_logs/2020-05-14T22_31_39_969Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile React.js (create-react-app) multi app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to lang-flash.
remote:
To https://git.heroku.com/lang-flash.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/lang-flash.git'
Edit: I forgot to mention that it appears that my react scripts file has full permissions:
hey have you found the answer yet?
I tried:
if (process.env.NODE_ENV === "production"){
app.use(express.static(path.join(__dirname,"client", "build")))
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname,"client", "build", "index.html"));
});
}
and i have to npm install react-scripts in the server package.json file.
Also you have to put the "proxy": "http://localhost:5000" at the last curly brace in client package.json file. That proxy is the server port.
It works for me!

Error while trying to deploy React app to Heroku

I'm keep getting the following error when I'm trying to deploy to heroku:
remote: sh: 1: react-scripts: Permission denied
The app compiles and workes well locally, so i'm pretty sure it's something with the deployment settings.
I can't understand what's wrong... here is my nodejs server package.json:
{
"name": "app-server",
"version": "1.0.0",
"description": "Create-react-app with Express",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"author": "Roy",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"cors": "^2.8.4",
"dotenv": "^8.1.0",
"express": "^4.16.3"
},
"engines": {
"node": "10.5.0"
}
}
And here is my client package.json
{
"name": "client",
"version": "0.1.0",
"private": false,
"dependencies": {
"#material-ui/core": "^4.4.1",
"axios": "^0.19.0",
"color-temperature": "^0.2.7",
"concurrently": "^4.1.2",
"cors": "^2.8.5",
"downshift": "^3.2.14",
"express": "^4.17.1",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"path": "^0.12.7",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-md": "^1.12.3",
"react-moment": "^0.9.2",
"react-redux": "^7.0.2",
"react-reveal": "^1.2.2",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"react-toastify": "^5.3.2",
"reactstrap": "^8.0.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}
And here is the full error
remote: sh: 1: react-scripts: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! client#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the client#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging
output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.cG6aC/_logs/2019-09-20T12_27_39_563Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! weather-app-server#1.0.0 heroku-postbuild: `cd client && npm install && npm run
build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the weather-app-server#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging
output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.cG6aC/_logs/2019-09-20T12_27_39_576Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
Have you ignored node modules?
Have you checked that all module installations were correct without errors?
In your client package.json the proxy is localhost. Try to replace it with your backend url.

Resources