本文整理 Windows/macOS 安装 Node.js、配置 npm 国内镜像、使用 cnpm 及常见问题解决方案,用于提升包下载速度。
bashnode -v npm -v
.pkg 安装包并双击安装bashnode -v npm -v
bash# 安装 Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 安装 Node.js
brew install node
bashnpm --registry https://registry.npmmirror.com install 包名
bashnpm config set registry https://registry.npmmirror.com
# 验证
npm config get registry
bashecho "registry=https://registry.npmmirror.com" > .npmrc
bash# 全局安装 cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
# 使用 cnpm 安装包
cnpm install 包名
# 查看版本
cnpm -v
https://registry.npmmirror.comhttps://mirrors.huaweicloud.com/repository/npm/http://mirrors.cloud.tencent.com/npm/bashnpm cache clean -f
bashnpm cache clean -f
bash# macOS/Linux
rm -rf node_modules package-lock.json
# Windows
rd /s /q node_modules
del package-lock.json
bashnpm install
完成配置后可实现:
本文作者:苏皓明
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!