Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: Update Node to latest version

I would like to update my node version to latest version possible on my local machine. I am using Ubuntu 16.04. I am currently finding trouble to update with methods available to my best of knowledge. Please note that heroku-cli is up to date(as of yet).

$ check-node-version
node: 8.3.0
npm: 5.4.2
yarn: 1.2.1

Here are other important commands which may help

harman@manchanda: 04:14 pm ~ $ node -v
v8.3.0

harman@manchanda: 04:14 pm ~ $ which node
/usr/local/heroku/bin/node

harman@manchanda: 04:15 pm ~ $ nodejs -v
v8.7.0

harman@manchanda: 04:15 pm ~ $ which nodejs
/usr/bin/nodejs

harman@manchanda: 04:15 pm ~ $ heroku -v
heroku-cli/6.14.34-1fcf80e (linux-x64) node-v8.6.0

harman@manchanda: 04:15 pm ~ $ n
node/6.2.2
node/6.7.0
node/7.0.0
node/7.8.0
node/7.9.0
node/8.4.0
node/8.7.0

Let me know if any other information is needed for same?

like image 393
Harry Avatar asked Nov 08 '22 15:11

Harry


1 Answers

Assuming you have installed n package on your local machine, you can run

sudo n latest

to update Node to the latest version available (8.7.0 at the moment of writing this answer)

Or, if you want to use the latest Node in your heroku dyno:

  1. Open your local project's root
  2. Open package.json
  3. Add "engines": { "node": "8.7.0" }, like that:
{
   "name":"node-example",
   "version":"1.0.0",
   "description":"This example is so cool.",
   "main":"web.js",
   "scripts":{
      "test":"echo \"Error: no test specified\" && exit 1"
   },
   "keywords":[
      "example",
      "heroku"
   ],
   "author":"jane-doe",
   "license":"MIT",
   "engines":{
      "node":"8.7.0"
   }
}
  1. git add package.json && git commit -m "Specified node version"
  2. git push heroku master

Reference

like image 148
vanelizarov Avatar answered Nov 14 '22 23:11

vanelizarov