Node.js配置
原创2024年9月2日大约 1 分钟
Node.js配置(全网最详细教程
该文章由LXCODER2008,进行编写,相关内容来源于网络。
Node.js网址:https://nodejs.org/zh-cn
作者Github:https://github.com/lxcoder2008
Node.js安装指南版本介绍:LTS 长期稳定版本,Current 最新版本
安装后NPM的设置(全网最详细)
了解npm缓存和包的位置
- 全局安装:在任何文件夹都可以运行
npm install -g <package_name>
- 局部安装:在当前项目中建立包,在当前项目起作用
npm install <package_name>
重要
现在对于包的了解之后,我们来进行相关设置包、环境的位置(npm_global和npm_cache)
修改全局包的安装路径
首先打开命令提示符输入相关命令
npm config set prefix "D:\Program\Node.js\npm\npm_global"
npm config set cache "D:\Program\Node.js\npm\npm_cache"
配置环境变量
如何打开环境变量?
Win+R输入rundll32 sysdm.cpl,EditEnvironmentVariables
命令回车(想要管理员打开就按住Ctrl+Shift+Alt+Enter即可)
请对C:\Users\LXCODER2008\AppData\Local\npm
更换成你的路径
D:\Program\Node.js\npm\npm_global
配置国内镜像源
命令
查询当前使用的镜像源
npm get registry
设置为淘宝镜像源
npm config set registry https://registry.npmmirror.com/
还原为官方镜像源
npm config set registry https://registry.npmjs.org/