在Ubuntu 18.04上安装指定的node.js版本

in #cn5 years ago

尝试在一台Ubuntu 18.04的VPS上部署一个别人弄的项目,需要安装node.js以及npm等。可是使用Ubuntu自带的包管理器安装的node.js以及npm版本太低,导致部署项目时出一堆乱七八糟的问题。


(图源 :pixabay)

旧的安装方式

安装nodejs与npm使用的命令为:

sudo apt install nodejs
sudo apt install npm

安装之后查看版本号:

node -v
输出为:v8.10.0

npm -v
输出为:3.5.2

新的安装方式

为了解决版本的问题,我搜索了半天,最终在NodeSource Node.js Binary Distributions: Debian and Ubuntu based distributions找到了安装指南。

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

上述代码下载并执行setup_10.x这个脚本,这个脚本做了许多工作,比如说:

  • Populating apt-get cache...
  • Confirming "bionic" is supported...
  • Adding the NodeSource signing key to your keyring...
  • Creating apt sources list file for the NodeSource Node.js 10.x repo...
  • Running apt-get update for you...

执行完上述几项工作后,我们需要手动执行以下代码来安装Node.js 10.x 以及npm

sudo apt-get install -y nodejs

安装完成后查看版本号:

node -v
输出为:v10.16.0

npm -v
输出为:6.9.0

其它

尽管更新了node.js版本,但是项目我还是没有部署明白,哈哈,惭愧啊。不过依旧要每天进步一点,也不枉接触一次。

相关链接


Vote For Me As Witness
https://steemit.com/~witnesses type in oflyhigh and click VOTE

Vote @oflyhigh via Steemconnect
Thank you!

Sort:  

恭喜你!您的这篇文章入选 @justyy 今日 (2019-07-07) 榜单 【优秀的文章】, 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
@justyy 是CN区的见证人,请支持他,给他投票,或者设置justyy为见证人代理。感谢!@justyy的主要贡献:https://steemyy.com

Congratulations! This post has been selected by @justyy as today's (2019-07-07) 【Good Posts】, Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^

SteemIt 工具、API接口、机器人和教程
SteemIt Tools, Bots, APIs and Tutorial



If you believe what I am doing, please consider a spare vote voting me here, thank you very much indeed.

@justyy - the author of https://SteemYY.com and I have been a Steem Witness for more than a year now.

区块链中文第一大银行简介:你的比特币拿不了利息,但是你把比特币换成steem后就能拿利息了!

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Coin Marketplace

STEEM 0.27
TRX 0.12
JST 0.031
BTC 57908.48
ETH 2913.17
USDT 1.00
SBD 3.61