下载
地址:https://nodejs.org/zh-cn/download/prebuilt-installer


安装包

开始安装







安装完成

给文件夹添加权限

创建两个文件夹
node_cache
node_global

更新环境变量
修改环境变量,新的全局模块路径,这样在任何位置运行命令时都能够访问到这些模块。
npm config set prefix "D:\nodejs\node_global"
npm config set cache "D:\nodejs\node_cache"

配置环境变量
将原来的用户变量-> Path
D:\nodejs\node_global

手动创建【node_modules】文件夹

【系统变量】
添加Path-->变量名:NODE_PATH-> 变量值:D:\nodejs\node_global\node_modules


验证安装
win + R 打开命令行:输入 cmd

更换npm源为淘宝镜像源
1.先查看当前使用的镜像地址
npm config get registry
清空缓存,切换新源
npm cache clean --force

npm config set registry https://registry.npmmirror.com

国内镜像还有如下,根据自己的需要使用:
腾讯
npm config set http://mirrors.cloud.tencent.com/npm/
华为
npm config set https://mirrors.huaweicloud.com/repository/npm/
中科大镜像
npm config set https://registry.npmjs.org/
查看更换成功
npm config get registry

在win+R 输入cmd 窗口中输入以下命令测试能否正常使用
npm install express -g
npm报错
xx packages are looking for funding run `npm fund` for details (解决办法)
解决方案: 这个打赏是资源的,因此我们选择不打赏(即在命令后面加 --no-fund)即可解决。
如: 本次执行的命令为:npm i nodemon -g
则: 我们在命令后面加上**--no-fund** 即可解决:npm i nodemon -g --no-fund