Ubuntu16 升級 Node.js 版本

wangchunbo發表於2020-05-21
root@iZuf68dv3a3meuxzjoj8ueZ:/var/www/html# cd meedu-backend && yarn install
yarn install v1.19.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error eslint@5.16.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.8.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
sudo npm intsall n -g
sudo n stable

執行後本人的結果:


root@iZuf68dv3a3meuxzjoj8ueZ:/var/www/html/meedu-backend# sudo npm install n -g
sudo: unable to resolve host iZuf68dv3a3meuxzjoj8ueZ
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@6.5.1
updated 1 package in 1.749s


   ╭──────────────────────────────────────╮
   │                                      │
   │   Update available 5.7.1 → 6.14.5    │
   │      Run npm i -g npm to update      │
   │                                      │
   ╰──────────────────────────────────────╯

root@iZuf68dv3a3meuxzjoj8ueZ:/var/www/html/meedu-backend# sudo n stable
sudo: unable to resolve host iZuf68dv3a3meuxzjoj8ueZ

  installing : node-v12.16.3
       mkdir : /usr/local/n/versions/node/12.16.3
       fetch : https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-x64.tar.xz
   installed : v12.16.3 (with npm 6.14.4)

再次執行 yarn install

root@iZuf68dv3a3meuxzjoj8ueZ:/var/www/html/meedu-backend# yarn install
yarn install v1.19.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > copy-webpack-plugin@5.1.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > html-webpack-plugin@3.2.0" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
Done in 8.72s.

它提供了幾個升級命令引數:

n 顯示已安裝的Node版本;
n latest 安裝最新版本的Node;
n stable 安裝最新穩定版本Node;
n lts 安裝最新長期維護版的Node;
n version 根據提供版本號安裝Node。

本作品採用《CC 協議》,轉載必須註明作者和本文連結

上海PHP自學中心-免費程式設計視訊教學|
7Dn78VKKcW.jpg!large
S3d25uqwht.png!large

相關文章