安装最新版

  • Windows 和 MacOS 都是下载安装包,然后打开安装包进行安装
  • 安装包下载地址:https://nodejs.org/en/download/
  • 建议安装 LTS 版本,请定期更新,避免使用时出现奇怪的报错
  • 安装 Node.js 后就支持 npm 命令了
  • 安装后如果npm命令无法执行,重新打开下CMD终端

npm 替换镜像源

查看当前源

npm config get registry

切换为 腾讯云 镜像源

npm config set registry http://mirrors.cloud.tencent.com/npm/

切换为 华为云 镜像源

npm config set registry https://mirrors.huaweicloud.com/repository/npm/

切换为 淘宝 镜像源(据说要关闭了)

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

换回官方源 registry.npmjs.org

npm config set registry https://registry.npmjs.org/

针对某个文件夹目录设定 npm 镜像源

在目录创建 .npmrc 文件,并在文件中写入以下内容(链接可以换成自己喜欢的镜像源)

registry=http://mirrors.cloud.tencent.com/npm/


回到顶部

Copyright © 2017-2024 1px.run (像素教程) Distributed by an MIT license.

Site updated at 2024-04-23 12:45