Ubuntu安装nodejs,指定版本nodejs

1. 更新apt-get

1 sudo apt-get update

2. 安装nodejs

1 sudo apt-get install nodejs

3. 安装nodejs指定版本,包含npm(替换数字即可)

1 curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
2 sudo apt-get install -y nodejs

4. npm若报错

(1)关闭命令窗口再打开

(2)不可行时再执行以下命令后,重新启动bash

1 sudo apt install note
2 sudo apt-get install -y build-essential

5. 查看npm源

sudo npm config get registry

6. 设置npm包为淘宝镜像源

1 sudo npm config set registry https://registry.npm.taobao.org

7. 安装yarn

1 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
2 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
3 sudo apt update
4 sudo apt install yarn
5 yarn --version

8. 卸载nodejs

1 sudo apt-get remove nodejs

9. 拷贝win10文件夹到utuntu,如拷贝win10的 D盘下的文件夹demo到ubuntu的 /home/目录,执行如下命令

1 scp -r /mnt/d/demo /home/

 

posted @ 2020-12-16 11:14  jianghongyun  阅读(10530)  评论(0编辑  收藏  举报