安装Nodejs常见问题
安装步骤
- 1、前往nodejs官网下载安装软件:https://nodejs.org/zh-cn/
- 2、点击下一步继续安装,安装完成,在命令输入:node -v,npm -v,查看版本,即是安装成功
- 3、随便在计算机哪个盘建一个全局目录,比如我的在E盘:E:\nodejs\node_global
- 4、设置nodejs全局目录,所有以全局安装的包都被安装在这,打开nodejs命令行窗口Node.js command prompt或vscode终端(快捷键Ctrl+~);
使用命令行设置:
npm config set cache "E:\nodejs\node_cache"
npm config set prefix "E:\nodejs\node_global"
设置环境变量:
用户变量设置:
将用户变量中 PATH 的值改成 E:\nodejs\node_global(node_global的路径),
没有PATH,可以直接添加
系统变量设置:
添加变量 NODE_PATH 值为:E:\nodejs\node_modules(nodejs下的node_modules路径)
修改镜像:原镜像(npm config set registry https://registry.npmjs.org/)
修改为淘宝镜像:
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
有的时候,可能使用的是yarn,那么yarn 怎么设置源?
1. 安装:npm install -g yarn
2. 修改源:yarn config set registry https://registry.npm.taobao.org
安装cnpm或者tnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
或者
npm install -g tnpm --registry=http://registry.npm.alibaba-inc.com
!!! note
查看当前配置:npm config list
git常见的几种命令
1.git init