5

我想在我的本地机器上将我的节点版本更新为最新版本。我正在使用 Ubuntu 16.04。我目前在使用我所知的可用方法进行更新时遇到了麻烦。请注意,这heroku-cli是最新的(到目前为止)。

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

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

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

让我知道是否需要任何其他信息?

4

1 回答 1

1

假设你已经n在本地机器上安装了包,你可以运行

sudo n latest

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

或者,如果你想在你的 heroku dyno 中使用最新的节点:

  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"
   }
}
  1. git add package.json && git commit -m "Specified node version"
  2. git push heroku master

参考

于 2017-10-13T12:43:23.913 回答