I'm trying to push my nodejs, express (backend) and react (font end) with
git push heroku master.
But have rejected:
-----> 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): 10.15.1
engines.npm (package.json): 6.4.1
Resolving node version 10.15.1...
Downloading and installing node 10.15.1...
npm 6.4.1 already installed with node
-----> Restoring cache
- node_modules
-----> Building dependencies
Installing node modules (package.json)
removed 231 packages and audited 201 packages in 3.657s
found 0 vulnerabilities
Running heroku-postbuild
> twituet#1.0.0 heroku-postbuild /tmp/build_fcf0465a8c2c68ad9a71497722565a7a
> cd client && npm && npm run build
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
completion, config, create, ddp, dedupe, deprecate,
dist-tag, docs, doctor, edit, explore, get, help,
help-search, hook, i, init, install, install-test, it, link,
list, ln, login, logout, ls, outdated, owner, pack, ping,
prefix, profile, prune, publish, rb, rebuild, repo, restart,
root, run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/app/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#6.4.1 /tmp/build_fcf0465a8c2c68ad9a71497722565a7a/.heroku/node/lib/node_modules/npm
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! twituet#1.0.0 heroku-postbuild: `cd client && npm && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the twituet#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.x0XkK/_logs/2019-02-24T14_05_47_120Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Here is my package.json
{
"name": "twituet",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"heroku-postbuild": "cd client && npm && npm run build"
},
"keywords": [],
"author": "vuong xuan",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"cors": "^2.8.5",
"express": "^4.16.4",
"mongoose": "^5.4.14",
"morgan": "^1.9.1"
},
"engines": {
"node": "10.15.1",
"npm": "6.4.1"
}
}
What i'm doing wrong. Pls help me...
I tried this solution but it didnt work
Push rejected, failed to compile Node.js app heroku
Since you are executing npm command without passing any argument that is why is failing.
Look at this line "heroku-postbuild": "cd client && npm && npm run build"
And change it to "heroku-postbuild": "cd client && npm install && npm run build"
npm <command> is the correct format of npm commands.
For more details, you can refer the npm doc - https://docs.npmjs.com/cli/npm
Use "heroku-postbuild": "echo Skip builds on Heroku"
This fixed my problem!
Related
so im trying to deploy my expressjs server , i've already done the login between heroku and github but after i execute the command git push heroku master i get this type of error
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 14.x...
Downloading and installing node 14.17.3...
Using default npm version: 6.14.13
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> bcrypt#5.0.1 install /tmp/build_e68eccdb/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! bcrypt#5.0.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the bcrypt#5.0.1 install 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.F7UGs/_logs/2021-07-17T18_32_02_636Z-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://devcenter.heroku.com/articles/node-best-practices#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
this is package.json
{
"name": "Server",
"version": "1.0.0",
"description": "",
"main": "Server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.4",
"nexmo": "^2.9.1",
"nodemailer": "^6.6.0",
"textbelt": "0.0.4",
"twilio": "^3.61.0"
}
}
i tried deleting node_modules and package-lock.json and reinstall them again but it doesnt work
is there any solution for this ?
Thanks !
I'm trying to use the Heroku CLI to get a MERN app online. The app works perfectly locally but when I try to use git to push the app onto Heroku I get the following error message:
remote: Running heroku-postbuild
remote:
remote: > exercise-logger#1.0.0 heroku-postbuild /tmp/build_431a136c
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix exercise-logger && npm run build --prefix exercise-logger
remote:
remote: up to date in 0.22s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_431a136c/exercise-logger/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_431a136c/exercise-logger/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.yesMz/_logs/2021-05-30T17_32_30_947Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! exercise-logger#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix exercise-logger && npm run build --prefix exercise-logger`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the exercise-logger#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.yesMz/_logs/2021-05-30T17_32_30_973Z-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_modules checked into source control
remote: https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
The thrust of it seems to be that it can't find the root package.json file, even though it's definitely there. In fact, here it is:
"name": "exercise-logger",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"axios": "^0.21.1",
"bcrypt": "^5.0.1",
"concurrently": "^6.0.2",
"config": "^3.3.6",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-validator": "^6.10.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.3"
},
"devDependencies": {},
"scripts": {
"start": "node server.js",
"build": "cd client && npm run build",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run start\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"engines": {
"node": "14.x",
"npm": "6.x"
},
"author": "",
"license": "ISC"
}
I have tried what seems to be a common fix which is manually deleting the .git folder in the directory for the React app but doesn't seem to have fixed it.
The whole code is on Github here.
Can anyone help? I've been working on this project for quite a while so it's really frustrating to fall at the final hurdle like this. I've not really done anything like this before so not really sure where to start troubleshooting!
Thanks
Im trying to deploy my MERN stack app to Heroku, I have done the necessary configuration on my package.json file, I have tried both Heroku CLI and Github Deploy at Dashboard Heroku but somehow it doesn't deploys... I have heroku postbuild script, which i checked on multiple sites and confirmed
here is my package.json;
{
"name": "devconnector",
"version": "1.0.0",
"description": "Social Network for Developers",
"main": "server.js",
"scripts": {
"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"
},
"engines": {
"node": "14.11.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.3.2",
"express": "^4.17.1",
"express-validator": "^6.6.1",
"gravatar": "^1.8.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.7",
"request": "^2.88.2"
},
"devDependencies": {
"concurrently": "^5.3.0",
"nodemon": "^2.0.4"
}
}
here is the error log;
-----> 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): 14.11.0
engines.npm (package.json): unspecified (use default)
Resolving node version 14.11.0...
Downloading and installing node 14.11.0...
Using default npm version: 6.14.8
-----> Installing dependencies
Installing node modules
> nodemon#2.0.4 postinstall /tmp/build_704248b1_/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
added 324 packages in 7.74s
-----> Build
Running heroku-postbuild
> devconnector#1.0.0 heroku-postbuild /tmp/build_704248b1_
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
up to date in 0.245s
found 0 vulnerabilities
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /tmp/build_704248b1_/client/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_704248b1_/client/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.TlmrF/_logs/2020-10-05T13_06_26_346Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 254
npm ERR! devconnector#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix
client && npm run build --prefix client`
npm ERR! Exit status 254
npm ERR!
npm ERR! Failed at the devconnector#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.TlmrF/_logs/2020-10-05T13_06_26_372Z-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
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I had tried to deploy a MERN stack application on heroku. I had followed the procedure given in the heroku documentation. But, somehow I am unable to deploy the application to heroku.
The following is my server.js code:
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const path = require('path');
const items = require('./routes/api/items');
const app = express();
app.use(bodyParser.json());
const db = require('./config/keys').mongoURI;
mongoose
.connect(db)
.then(() => console.log('MongoDB Connected...'))
.catch(err => console.log(err));
app.use('/api/items', items);
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Server started on port ${port}`));
The following is my package.json file in the server folder:
{
"name": "mern_shopping_list",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"client-install" : "npm install --prefix client",
"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": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"concurrently": "^5.1.0",
"express": "^4.17.1",
"mongoose": "^5.9.0"
},
"devDependencies": {
"nodemon": "^2.0.2"
}
}
The error I am getting is the following:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > mern_shopping_list#1.0.0 heroku-postbuild
/tmp/build_6dafb80a10b85bd553ee344141227145
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix
client
remote:
remote: up to date in 0.284s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_6dafb80a10b85bd553ee344141227145/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open
'/tmp/build_6dafb80a10b85bd553ee344141227145/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.2Rtdv/_logs/2020-02-15T15_35_57_654Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! mern_shopping_list#1.0.0 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 mern_shopping_list#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.2Rtdv/_logs/2020-02-15T15_35_57_666Z-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_modules checked into source control
remote: https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
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 damp-anchorage-46764.
remote:
To https://git.heroku.com/damp-anchorage-46764.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/damp-anchorage-46764.git'
I had tried out some of the links online but none of them is giving the desired result. Can anybody suggest me how to fix this?
cd to your /client
remove .git folder
rm -rf .git
also reset git via this command:
git rm --cached . -rf
As Mina Amir mentioned your changes has already tracked by the git inside your client directory and wont be tracked again with your server/main git in your commits
I got this problem, when I made a copy of my project and try to deploy,
Copy your backend and client without node_modules
then try to npm install in your backend and client folders,
then try to run your application,
in this point I got an error something called "babel-jest" dependency so I installed it and edited it's version to this "^24.8.0" manually in package.json, and I run the npm install in root folder(backend) again ,then I cloud recover the error and run the application,
after that I started to deployment process, I followed below steps it works.
https://www.youtube.com/watch?v=qdoiwouykAg&list=PL8E3OP1AP-EneRlZoCIQ996os2DLegipk&index=3&t=873s
try to remove .git folder from /client, because main .git folder in the root does not see /client/package.json and not tracking any changes inside /client.
after that commit everything from the beginning in the root folder
If you are still having this issue,, I faced a similar issue and what solved my problem is simply rename my client folder to "client" to match the name on that path specified. Hope someone finds this helpful and saves time
It happened to me as well. Here is the exact solution:-
The problem is due to two .git folders. There is one .git folder in the root directory but another one in the "client" directory.
To solve this issue, delete both the .git folders and reinitialize git in the root directory using git init after having deleted both .git folders.
(Note that ReactJS automatically created its own .git folder which causes this problem and we have to delete it at all costs. Further in case you are doing a follow-along of Brad Traversy's tutorial, he skipped telling this important part as well. That's a mistake on his part)
I am trying to deploy a simple node.js express-based application to heroku, something which is apparently very basic: https://devcenter.heroku.com/articles/nodejs
Here is my package.json:
{
"name": "cours-lic3-blois",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "*",
"ejs": "*",
"github-flavored-markdown": "*",
"less-middleware": "*"
},
"engines": {
"node": "0.8.8",
"npm": "1.1.65"
}
}
When I git push heroku master I got the following trace:
-----> Heroku receiving push
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.8.8
Using npm version: 1.1.65
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm ERR! Error: ENOENT, chmod '/tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 2.6.32-348-ec2
npm ERR! command "/tmp/node-node-tonf/bin/node" "/tmp/node-npm-NG88/cli.js" "rebuild"
npm ERR! cwd /tmp/build_1suuxlhd9s8n6
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.65
npm ERR! path /tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_1suuxlhd9s8n6/npm-debug.log
npm ERR! not ok code 0
! Failed to rebuild dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git#heroku.com:fast-everglades-2007.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:fast-everglades-2007.git'
I tried to tweak various versions in my package.json but to no avail. I am developing on windows and it might be possible this ENOENT issue is due to some filemode issue.
I got this fixed by:
Making sure Procfile is committed into git
Removing the node_modules/ folder and committing that into git (git rm -r node_modules/)
Afterwards, I did the git push heroku master then the error disappeared.
I had this problem, and it was because:
I keep node_modules in version control
I had bin in my .gitignore file
npm was attempting to chmod express/bin/express, but due to my .gitignore this file wasn't in git and thus was not being cloned during the deploy, so it failed. I didn't notice it because a local npm install would create the bin/express file as usual.
Removing bin from .gitignore and committing the missing files solved the problem for me.
Heroku team, could you please consider configuring npm to use npm install --no-bin-links --production by default, or creating an environment variable to let users set that flag. This is a serious bug in node installs. Removing the bin directory from my .gitignore (as suggested below) enabled me to deploy, but it breaks using git effectively in a cross-platform development environment, requiring an explicit npm rebuild on every git pull where node_modules might have changed.
NPM best practice is to avoid having node_modules in .gitignore (see http://www.futurealoof.com/posts/nodemodules-in-git.html ).
I believe --no-bin-links will provide the best of both worlds, enabling deploys of node_modules where the bin directory has been excluded, supporting npm rebuild, but not failing when a bin link is created.
I submitted a pull request here: https://github.com/heroku/heroku-buildpack-nodejs/pull/33
Thanks!
similar issue was fixed by renaming gruntfile.js to Gruntfile.js
I had a similar problem a few days ago, I think it was because I imported a module created by me and that was what gave the error;
I corrected it like this:
I called the module "path"
const path = require ("path")
and then where my module was imported I made a join of the file path
const myModule = require (path.join (__ dirname, 'MyModule.js'))