Heroku:将节点更新到最新版本

Har*_*rry 5 javascript heroku node.js n heroku-cli

我想在我的本地计算机上将节点版本更新为最新版本.我正在使用Ubuntu 16.04.我目前很难用我最了解的方法更新.请注意,这heroku-cli是最新的(截至目前).

$ check-node-version
node: 8.3.0
npm: 5.4.2
yarn: 1.2.1
Run Code Online (Sandbox Code Playgroud)

以下是其他可能有用的重要命令

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
Run Code Online (Sandbox Code Playgroud)

如果需要任何其他信息,请告诉我吗?

van*_*rov 1

假设您已经n在本地计算机上安装了软件包,您可以运行

sudo n latest
Run Code Online (Sandbox Code Playgroud)

将 Node 更新到可用的最新版本(在撰写此答案时为 8.7.0)

或者,如果您想在 heroku dyno 中使用最新的 Node:

  1. 打开本地项目的根目录
  2. 打开package.json
  3. "engines": { "node": "8.7.0" },像这样添加:
{
   "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"
   }
}
Run Code Online (Sandbox Code Playgroud)
  1. git add package.json && git commit -m "Specified node version"
  2. git push heroku master

参考