when I try to push code on Heroku, the build/deploy fail because of node problem.
Console log
cd dungeon-diary
heroku buildpacks:set https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/emberjs.tgz
git push heroku master
Output console with error
remote: Building source:
remote:
remote: -----> emberjs app detected
remote: -----> Setting NPM_CONFIG_PRODUCTION to false to install ember-cli toolchain
remote: -----> Fetching buildpack heroku/nodejs-v98
remote: -----> Node.js detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 10.* || >= 12
remote: engines.npm (package.json): 6.x
remote:
remote: Resolving node version 10.* || >= 12 via semver.io...
remote: Downloading and installing node 14.7.0...
remote: Unable to download node 14.7.0; does it exist?**
remote:
remote: -----> Build failed
package.json
"engines": {
"node": "10.* || >= 12"
},
The problem was...
in the log you can see, the console choose node 14.7.0 by itself,
but for Heroku it was unacceptable. So I had to explicitly write which version use ( to avoid 14.7.0 ) and it starts work :)
...weird for me why console choose the unsupported version :)
Related
I am not able to push my files/repo to heroku it gives an error as follows
$ git push -f heroku main
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: -----> Build
remote: Running heroku-postbuild
remote: > ecommerce#1.0.0 heroku-postbuild
remote: > NPM_CONFIG_PRODUCTION=false && npm install --prefix frontend && npm run build --prefix frontend
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
And yes in my package.json folder I have mentioned the versions of node and npm in engine section
Please anyone help why I am not able to push in heroku
If you use yarn:
git rm yarn.lock
git push heroku master
If you use npm:
git rm package-lock.json
git push heroku master
git push heroku master
Setting Heroku stack. In this case to heroku-20
heroku stack:set heroku-20
then push
I am willing to install a custom build of libvips with sharp on heroku. I use buildpacks that run without errors, but when it comes to node-gyp compilation, it fails here saying it cannot access /app/vendor/vips/lib/libvips-cpp.so. When I run the build without installing sharp and then connect with heroku run bash, I can see that the file is at this location.
Why node-gyp cannot find it then ?
My buildpacks
=== my-site Buildpack URLs
1. heroku-community/apt
2. https://github.com/lechinoix/heroku-buildpack-vips
3. heroku/nodejs
The error
remote: -----> vips (heroku-20 stack) app detected
remote: -----> Vendoring binaries
remote: Fetching /tmp/codon/tmp/buildpacks/2ef659928923e1b5ae4bf85b886e53d084c6a3d4/build/heroku-20.tar.gz
remote: Changing permissions on libvips folder
remote: -----> Configuring build environment
remote: -----> Building runtime environment
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=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 14.x...
remote: Downloading and installing node 14.18.1...
remote: Using default npm version: 6.14.15
remote:
remote: -----> Restoring cache
remote: Caching has been disabled because NODE_MODULES_CACHE=false
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json)
remote:
remote: > sharp#0.28.1 install /tmp/build_1f4c5c03/node_modules/sharp
remote: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
remote:
remote: sharp: Detected globally-installed libvips v8.10.6
remote: sharp: Building from source via node-gyp
remote: readelf: Error: '/app/vendor/vips/lib/libvips-cpp.so': No such file
remote: gyp: Call to 'if readelf -Ws "$(PKG_CONFIG_PATH="/tmp/build_1f4c5c03/.apt/usr/lib/x86_64-linux-gnu/pkgconfig:/tmp/build_1f4c5c03/.apt/usr/lib/i386-linux-gnu/pkgconfig:/tmp/build_1f4c5c03/.apt/usr/lib/pkgconfig::/tmp/build_1f4c5c03/vendor/vips/lib/pkgconfig:/tmp/build_1f4c5c03/.apt/usr/lib/x86_64-linux-gnu/pkgconfig:/tmp/build_1f4c5c03/.apt/usr/lib/i386-linux-gnu/pkgconfig:/tmp/build_1f4c5c03/.apt/usr/lib/pkgconfig::/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --variable libdir vips-cpp)/libvips-cpp.so" | c++filt | grep -qF __cxx11;then echo "1";else echo "0";fi' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
Thank you so much for your help !
Finally found that heroku is creating the whole /app folder in a directory /tmp/build_1f4c5c03 that also contains the freshly installed vendors. In my .pc files, the package is located in /app so it cannot be found. I used a heroku-prebuild npm script to sed inplace the paths :
TMP_DIR=$(pwd)
for file in $(grep -rl /app/vendor ${TMP_DIR}/vendor/vips/lib/pkgconfig)
do
sed -i "s+/app/vendor+${TMP_DIR}/vendor+g" $file
done
Not perfectly sure it is the best way to do...
I encountered the error mentioned in the Title.
I have referred to a few relevant Heroku articles and tried their suggested changes including specifying the exact version of Node.js, Yarn, or npm that I'm using locally , but that still didn't work.
Here's the relevant sections extracted from my package.json:
"engines": {
"node": "14.18.0",
"npm": "6.14.15",
"yarn": "1.19.1"
},
"ember": {
"edition": "octane"
}
Here's the deployment log:
Enumerating objects: 1134, done.
Counting objects: 100% (1134/1134), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1027/1027), done.
Writing objects: 100% (1134/1134), 309.32 KiB | 2.64 MiB/s, done.
Total 1134 (delta 581), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/emberjs.tgz
remote: -----> emberjs app detected
remote: -----> Setting NPM_CONFIG_PRODUCTION to false to install ember-cli toolchain
remote: -----> Fetching buildpack heroku/nodejs-v98
remote: -----> Node.js detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_PRODUCTION=false
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): 14.18.0
remote: engines.npm (package.json): 6.14.15
remote:
remote: Downloading and installing node 14.18.0...
remote: Unable to download node 14.18.0; does it exist?
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: -----> Failed trying to compile heroku/nodejs-v98
remote: ! Push rejected, failed to compile emberjs app.
remote:
remote: ! Push failed
remote: !
According to this Heroku page, versions 12.x, 14.x, and 16.x are supported.
When such version numbers are literally specified in package.json file, during the Heroku build process, those will be resolved to the latest patch version, e.g. 12.22.7, 14.18.1, and 16.13.0 respectively as of the time of writing.
Somehow Heroku was unable to download the latest version of every major series.
In my original question, I used version 14.18.0 in my local and that version was specified in package.json. It appears that Heroku was also not able to download that version.
I double checked this Heroku Help page and noticed version 12.16.3 is given in the example when illustrating how to compare Node and npm versions. I updated my package.json to use 12.16.3 and retried the the deployment and it was successful.
I tried to search but unfortunately I couldn't find any Heroku Help page that specifies the exact Node.js version numbers that they support.
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 327 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 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_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.11.1
remote: engines.npm (package.json): 5.6.0
remote:
remote: Resolving node version 8.11.1...
remote: Downloading and installing node 8.11.1...
remote: npm 5.6.0 already installed with node
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: up to date in 4.243s
remote:
remote: -----> Caching build
remote: Clearing previous node cache
remote: Saving 2 cacheDirectories (default):
remote: - node_modules
remote: - bower_components (nothing to cache)
remote:
remote: -----> Pruning devDependencies
remote: Skipping because npm 5.6.0 sometimes fails when running 'npm
prune' due to a known issue
remote: https://github.com/npm/npm/issues/19356
remote:
remote: You can silence this warning by updating to at least npm 5.7.1 in your package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 28.5M
remote: -----> Launching...
remote: Released v6
remote: https://ashishkr.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/ashishkr.git
cfc5c8a..76b27d1 master -> master
I have also a Procfile in my project root and have like:
web: node server.js
on doing heroku config i get the following result :
MONGODB_URI: mongodb://:#ds163410.mlab.com:63410/ashishkr
i hide the username and password for the security concern but i am sure that the username and password which i have entered is absolutely correct!
in my package.json i have engines and start script also:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"engines": {
"node": "8.11.1",
"npm": "5.6.0"
},
Anykind of help is appreciated !!
Thanks !!
After updating the node server to version 6.11.1 in response to the recent security update email from Heroku, I cannot git push my local master changes any more. The server and app restarted fine after the update.
I have tried deleted and reinstalled all node_modules, committing the changes and the app runs without errors locally but I get the same build failure when trying to deploy the master. The only change I've made to the package.json file is adding the npm version which was previously unspecified.
From the logs the server build fails when installing node modules:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
Is force pushing the best/a good solution?
This is the full logs:
Counting objects: 18, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 8.80 KiB | 0 bytes/s, done.
Total 18 (delta 13), reused 0 (delta 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: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.11.1
remote: engines.npm (package.json): 5.3.0
remote:
remote: Downloading and installing node 6.11.1...
remote: Downloading and installing npm 5.3.0 (replacing version 3.10.10)...
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote: npm ERR! Cannot read property '0' of undefined
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-07-20T22_54_19_003Z-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
remote: Verifying deploy...
remote:
remote: ! Push rejected to app-name.
remote:
To https://git.heroku.com/app-name.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/app-name.git'
Thanks.
I got the same error message after updating to node 6.11.1 and npm 5.3.0. heroku support suggested that I run these commands:
heroku plugins:install heroku-repo
heroku repo:purge_cache -a APPNAME
git commit --allow-empty -m "Purge cache"
git push heroku master
... where "APPNAME" was the heroku identifier for my app.
That resolved the error and I did not have to revert to an earlier version of npm. I've asked for an explanation but they haven't responded yet (just asked a few minutes ago).
UPDATE 2017-07-27: heroku support responded and said, "We're still working on the root cause for this but it seems to be fairly intermittent." Now that I have installed the plugin (see above), I am running these steps to update my app:
heroku repo:purge_cache -a APPNAME
git push heroku master
That's been working reliably for me.