Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify node version in heroku

I have a Node project that I want to host on Heroku. I have explicitly defined node and npm versions in my package.json (located in the root directory), which looks like this:

{
 "name": "*********",
 "version": "1.0.0",
 "description": "**********",
 "engines": {
  "node": "8.x",
  "npm": "6.x"
 },
 "private": true,
 .....
 }

However, when I try to push the app to heroku. It still not read the node and npm version.

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:        Resolving node version 10.x...
remote:        Downloading and installing node 10.15.3...
remote:        Using default npm version: 6.4.1

Is there any solution for my case? Thank you anyway

like image 724
Vincent Wijaya Avatar asked Mar 26 '26 20:03

Vincent Wijaya


1 Answers

I resolved this by adding engines in package.json file

"name": "myApp",
"version": "1.0.0",
"engines": {
    "node": "14.17.0",
    "npm": "6.14.13"
},
"main": "index.ts",

reference link :-https://help.heroku.com/6235QYN4/why-is-my-node-js-build-failing-because-of-no-matching-node-versions

like image 110
Abhay Kumar Upadhyay Avatar answered Mar 29 '26 10:03

Abhay Kumar Upadhyay