文章目录
环境准备
安装 VS Code
winget install Microsoft.VisualStudioCode
安装插件
安装 git bash
winget install --id Git.Git -e --source winget
下载NFM
winget install Schniz.fnm
安装 NodeJS
fnm install v22.14.0
https://github.com/Schniz/fnm#powershell 按照readme设置完
fnm
设定环境变量
https://mirrors.tuna.tsinghua.edu.cn/help/nodejs-release/
export FNM_NODE_DIST_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/
然后正常使用 fnm 即可
fnm install <version>
fnm use v22.14.0
修改镜像
方法一:直接修改 npm 源
- 永久设置国内源
执行以下命令将 npm 源切换为国内镜像(如淘宝源、华为云源等):
npm config set registry https://registry.npmmirror.com # 推荐使用 npmmirror(原淘宝源新地址)[[3, 18]]
# 或
npm config set registry https://registry.npm.taobao.org # 旧版淘宝源地址[[7, 8, 19]]
验证是否成功:
npm config get registry # 输出应为设置的镜像地址[[7, 8, 11]]
- 临时使用国内源
若仅需单次使用国内源,可在命令中直接指定:
npx --registry https://registry.npmmirror.com <package-name> # 例如 npx electron-forge
- 关闭 SSL 严格模式(可选)
若遇到 SSL 证书问题,可关闭严格模式:
npm config set strict-ssl false # 关闭 SSL 验证
方法二:使用工具管理源(推荐)
- 安装
nrm
(源管理工具)
npm install -g nrm # 全局安装
- 查看和切换源
nrm ls # 列出所有可用源
nrm use taobao # 切换为淘宝源
nrm test taobao # 测试源速度
https://expo.dev/
https://react.dev/
https://reactnative.dev/