node.js安装指南

前言

·node 版本14.9.0
·windows10

node.js下载与安装

第一次安装不推荐使用最新版本
原因:对于依赖包在切换淘宝镜像源后仍无法安装的问题,直接切换node.js版本后问题便不复存在

下载步骤

打开官方下载地址

在这里插入图片描述
选择64位windows版本安装包
在这里插入图片描述

安装步骤

1/6在这里插入图片描述

2/6
在这里插入图片描述

3/6
在这里插入图片描述

4/6在这里插入图片描述

5/6
在这里插入图片描述

6/6在这里插入图片描述

安装完成后重启电脑使环境变量配置生效

验证安装结果

查看node和npm版本,返回对应版本号表示安装成功

C:\Users\shaohuang>node -v
v14.9.0

C:\Users\shanghuang>npm -v
6.14.10

npm配置

由于npm官方镜像源访问速度慢,所以推荐使用淘宝镜像源

方案一、安装cnpm [一劳永逸]

npm install -g cnpm --registry=https://registry.npmmirror.com

方案二、指定npm源

①直接指定npm源
npm config set registry https://registry.npmmirror.com
npm config get registry 
②单次使用指定npm源
npm install --registry=https://registry.npmmirror.com

至此就可以直接使用npm安装依赖项了~

问题汇总

①cannot be loaded because running scripts is disabled on this system

这个原因是由于脚本执行策略为严格模式,所以无法执行
解决方案】要使脚本能够执行,需要修改执行策略为Unrestricted 或 Bypass

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
或者
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
②The term ‘vue’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

刚开始直接使用npm install vue进行安装,报了以上错误
解决方案】全局安装vue-cli

npm install vue-cli -g

npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:npm ERR! https://npm.community

**【分析】**这是因为npm缓存所致,需要清理npm 缓存
【解决方案】
方法一:尝试清理缓存

npm cache clean -f

方法二:更新npm版本

npm install npm@latest -g --registry=https://registry.npmmirror.com
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值