Heroku Build Failed: "node_modules checked into source control" - heroku

I am deploying a site built upon MEAN stack on Heroku. While troubleshooting an issue I removed node_modules/ from my .gitignore file and ever since my app has been getting "Build failed" errors.
I readded node_modules/ to the file, but it seems the damage has been done as builds still fail.
One of the possible problems that is suggested in the log is:
"- node_modules checked into source control"
How do I go about undoing what I did?
-----> Deleting 1 files matching .slugignore patterns.
-----> Using set buildpack heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 0.10.x
engines.npm (package.json): 2.x.x
Resolving node version 0.10.x via semver.io...
Downloading and installing node 0.10.41...
Resolving npm version 2.x.x via semver.io...
Downloading and installing npm 2.14.15 (replacing version 1.4.29)...
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm#2, if not the
npm WARN deprecated latest stable version. To upgrade to npm#2, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm#2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules (exists - skipping)
- bower_components (not cached - skipping)
-----> Building dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> bson#0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
COPY Release/bson.node
make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
> bson#0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
COPY Release/bson.node
make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
> bson#0.2.22 install /tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
COPY Release/bson.node
make: Leaving directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
> phantomjs#1.9.19 install /tmp/build_###########/node_modules/phantomjs
> node install.js
PhantomJS not found on PATH
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /tmp/build_###########/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1450118671217/phantomjs-1.9.8-linux-x86_64 -> /tmp/build_###########/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /tmp/build_###########/node_modules/phantomjs/lib/phantom/bin/phantomjs
> kerberos#0.0.11 install /tmp/build_###########/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_###########/node_modules/kerberos/build'
CXX(target) Release/obj.target/kerberos/lib/kerberos.o
CXX(target) Release/obj.target/kerberos/lib/worker.o
CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
CC(target) Release/obj.target/kerberos/lib/base64.o
CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
SOLINK_MODULE(target) Release/obj.target/kerberos.node
COPY Release/kerberos.node
make: Leaving directory `/tmp/build_###########/node_modules/kerberos/build'
> ws#0.4.32 install /tmp/build_###########/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_###########/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
COPY Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
COPY Release/validation.node
make: Leaving directory `/tmp/build_###########/node_modules/ws/build'
> v8-profiler#5.2.12 preinstall /tmp/build_###########/node_modules/v8-profiler
>
> v8-profiler#5.2.12 install /tmp/build_###########/node_modules/v8-profiler
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! Linux 3.13.0-71-generic
npm ERR! argv "node" "/tmp/build_###########/.heroku/node/bin/npm" "rebuild"
npm ERR! node v0.10.41
npm ERR! npm v2.14.15
npm ERR! code ELIFECYCLE
npm ERR! v8-profiler#5.2.12 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the v8-profiler#5.2.12 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-profiler package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls v8-profiler
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_###########/npm-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://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
Love,
Heroku
! Push rejected, failed to compile Node.js app

Although you've re-added node_modules to your .gitignore, as you say, the damage has already been done. So you need to remove node_modules from your git repo. Try this:
git rm -r --cached node_modules
git commit -m 'Remove node_modules'
The first command recursively removes node_modules from the git repo without removing your local files, the second commits the removal.
You can then push your changes to Heroku.

Related

Heroku: Build Failed

-----> Building on the Heroku-20 stack
-----> 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.16.0...
Using default npm version: 6.14.11
-----> Restoring cache
Cached directories were not restored due to a change in version of node, npm, yarn or stack
Module installation may take longer for this build
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> canvas#2.6.1 install /tmp/build_dc388f20_/node_modules/canvas
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! canvas#2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the canvas#2.6.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.40jbb/_logs/2021-03-05T17_30_09_270Z-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
How do i fix this?

Error "node_modules checked into source control" when trying to run a discord bot

When i try to run the bot in Heroku, it keeps giving me the same error and not turning the bot on. How would i go on to fix this issue? All the files and node modules are already installed in the github repository
-----> 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.19.1...
Using default npm version: 6.14.8
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> #discordjs/opus#0.3.2 install /tmp/build_8234188f_/node_modules/#discordjs/opus
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! #discordjs/opus#0.3.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the #discordjs/opus#0.3.2 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.tAPfy/_logs/2020-11-22T22_42_39_963Z-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
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed

Issue with deployment of sails.js app on Heroku - npm error - package: sailshq/body-parser

To start, current configuration - Development machine:
Node version: 8.4.0
Npm: 5.3.0 (comes with 8.4)
Sails: ~0.12.13
Source control system: Github
Deployment host: Heroku
I followed following guide: https://vort3x.me/sailsjs-heroku/ (except the heroku git part, working with github)
But I am rather stuck when I press deploy in Heroku, the following happens:
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=false
-----> Installing binaries
engines.node (package.json): 8.4.0
engines.npm (package.json): unspecified (use default)
Resolving node version 8.4.0...
Downloading and installing node 8.4.0...
Detected package-lock.json: defaulting npm to version 5.x.x
Bootstrapping npm 5.x.x (replacing 5.3.0)...
npm 5.3.0 installed
-----> Restoring cache
Skipping cache restore (disabled)
-----> Building dependencies
Installing node modules (package.json + package-lock)
npm ERR! path /tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/sails-fec6f6e5/node_modules/#sailshq/body-parser
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/sails-fec6f6e5/node_modules/#sailshq/body-parser' -> '/tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/#sailshq/body-parser-9ed21a9f'
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! /app/.npm/_logs/2017-08-22T20_43_13_796Z-debug.log
-----> Build failed
And frankly I have no idea what to do about this, I thought first it was because I forgot to say engine 'node: 8.4.0' and that my cache was corrupted, so I tried disabling cache, but nothing so far.
It says to rename, but I have no control over dependencies within Sails.js?
Probably doing something wrong...
Thx and kind regards
PS: I will keep looking myself and answer if I find anything.
Just remove package-lock.json, commit and push to Heroku !

Installing npm package acs fails due to incompatibility with tar#0.1.13

I'm trying to install the package acs through npm, but it fails and says it's not compatible with tar#0.1.13.
However when I run npm -g list it says that my installed version of tar is 2.1.1.
➜ ~ npm info tar version
2.1.1
But when I try to install acs it fails due to incompatibility with tar. See logs below:
➜ ~ npm install -g acs#1.0.25
> ws#0.4.32 install
/usr/local/lib/node_modules/acs/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "acs#1.0.25"
npm ERR! node v0.12.7
npm ERR! npm v2.13.1
npm ERR! code ENOTSUP
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: tar#0.1.13
npm ERR! notsup Required: {"node":"~0.5.9 || 0.6 || 0.7 || 0.8"}
npm ERR! notsup Actual: {"npm":"2.13.1","node":"0.12.7"}
npm ERR! Please include the following file with any support request:
npm ERR! /Users/sinkensabe/npm-debug.log
I cant figure out why it says that it is incompatible with tar#0.1.13 when this is not a version that seems to be installed on my unix system.
Any help is appreciated!
Got it to work, not sure why though.. Removed everything related to node and installed node with homebrew. Then installing acs worked without any problems.
Followed the instructions here to remove node: http://tinyurl.com/qxyax6y

Using Magick++ in a node.js application on heroku

I'm trying to push a Node app to heroku, but I am using imagemagick-native and it seems that Heroku is having an issue with Magick++ - I've tried using custom build packs but can't seem to find one that supports Magick++. (1) Is this the issue (2) Is there any solution to run Magick++ on Heorku?
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.10.20
Using npm version: 1.3.11
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm WARN package.json upload#0.1.3 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
> bson#0.2.2 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
COPY Release/bson.node
make: Leaving directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
> kerberos#0.0.3 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'
SOLINK_MODULE(target) Release/obj.target/kerberos.node
SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
COPY Release/kerberos.node
make: Leaving directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'
> imagemagick-native#0.2.8 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/imagemagick-native
> node-gyp rebuild
/bin/sh: Magick++-config: not found
gyp: Call to 'Magick++-config --ldflags --libs' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/tmp/node-npm-k25M/node_modules/node-gyp/lib/configure.js:424:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.8.11-ec2
gyp ERR! command "node" "/tmp/node-npm-k25M/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/imagemagick-native
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
! Failed to rebuild dependencies with npm
! Push rejected, failed to compile Node.js app
I've made some progress on this:
Use the multi buildpack:
heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
So that it can load the apt-buildpack in addition to the nodejs one. List your builpacks in .buildpacks:
https://github.com/ddollar/heroku-buildpack-apt.git
https://github.com/heroku/heroku-buildpack-nodejs.git
Now install libmagick++-dev through apt by listing it in a file called Aptfile.
Now if you include imagemagick-native in your package.json:
"dependencies": {
"imagemagick-native": "1.7.0"
}
It will start compiling. And although $CPATH is set properly by the APT package, node-gyp somehow doesn't seem to forward it to gcc.
This causes the following error:
remote: > imagemagick-native#1.7.0 install /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native
remote: > node-gyp rebuild
remote:
remote: make: Entering directory `/tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build'
remote: CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
remote: In file included from ../src/imagemagick.cc:9:
remote: ../src/imagemagick.h:1:22: warning: Magick++.h: No such file or directory
So it doesn't solve the problem yet, but I think it's on the right track. Still trying to figure out what's up with node-gyp.
Update
To workaround that problem fork the nodejs buildpack and add the following lines to the top of bin/compile:
path=`echo "$INCLUDE_PATH" | cut -d : -f 1`
export CXX="`which g++` -I$path/ImageMagick"
Works on cedar-14. For the deprecated cedar you would need to use imagemagick-native v1.22.

Resources