win10安装linux系统及下载node、npm及n管理node版本

1、win+r打开cmd 输入wsl --install

2、安装完成后貌似要启用电脑的开发者模式

  

 3、打开电脑应用商店(直接点击左下角菜单输入应用商店),搜ubuntu并下载

 4、下载成功后双击进入ubuntu,第一次进入需输入用户名和密码新建用户

 5、然后Ubuntu需换源,在窗口输入

sudo vi /etc/apt/sources.list

 如果没有修改权限的话先更改文件权限再继续更换源:

sudo chmod 777 /etc/apt/source.list

 然后按 i 进入编辑模式,把原内容删掉,换成如下内容(ctrl+c后在ubuntu窗口右键即可粘贴内容?):

#阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

 粘贴好后按esc退出编辑模式,再输入  :wq!  保存并返回

 修改完之后逐步输入下面两条命令更新配置

sudo apt-get update
sudo apt-get upgrade

 等更新下载后源就换好了

7、开始安装node,继续在窗口内输入 

sudo apt-get install nodejs 
sudo apt install npm

等下载完后node及npm即下载完成,如需更换源可执行以下代码

sudo npm config set registry https://registry.npm.taobao.org 
sudo npm config list(查看配置用)

8、安装n方便管理切换node版本

sudo npm install n -g
sudo n stable (更新到稳定版本)

安装完后直接sudo n install x.x.x(node版本)即可安装不同node版本,输入n,↑↓选择需使用版本,回车后即可使用所选择node版本

tips: ubuntu npm安装有时报错npm ERR! Error: EACCES: permission denied, access…… 是没权限,在命令前加sudo即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值