This shows you the differences between two versions of the page.
|
network:webdev:nodejs [2021/07/18 09:21] zhwiki created |
network:webdev:nodejs [2021/07/18 10:08] (current) zhwiki |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| Windows 7 环境下可以使用的最高LTS版本为V12,最新版本为V12.22.3,2021-07-05发布。 | Windows 7 环境下可以使用的最高LTS版本为V12,最新版本为V12.22.3,2021-07-05发布。 | ||
| + | |||
| + | ===== NPM ===== | ||
| + | |||
| + | npm全称Node Package Manager,是node.js的模块依赖管理工具。由于npm的源在国外,所以国内用户使用起来各种不方便。可以换成国内npm镜像。 | ||
| + | |||
| + | 淘宝npm镜像 | ||
| + | |||
| + | 搜索地址:https://npm.taobao.org/ | ||
| + | registry地址:https://registry.npm.taobao.org/ | ||
| + | |||
| + | cnpmjs镜像 | ||
| + | |||
| + | 搜索地址:https://cnpmjs.org/ | ||
| + | registry地址:https://r.cnpmjs.org/ | ||
| + | |||
| + | 如何使用 | ||
| + | |||
| + | 1. 临时使用 | ||
| + | |||
| + | npm --registry https://registry.npm.taobao.org install express | ||
| + | |||
| + | 2. 永久使用 | ||
| + | |||
| + | npm config set registry https://registry.npm.taobao.org | ||
| + | |||
| + | // 配置后可通过下面方式来验证是否成功 | ||
| + | npm config get registry | ||
| + | |||
| + | // 或者 | ||
| + | npm info express | ||
| + | |||
| + | 3. 使用cnpm | ||
| + | |||
| + | npm install -g cnpm --registry=https://registry.npm.taobao.org | ||
| + | |||
| + | // 使用 | ||
| + | cnpm install express | ||
| + | |||
| + | 4.还原配置 | ||
| + | |||
| + | //初始源 | ||
| + | https://registry.npmjs.org/ | ||
| + | npm config set registry https://registry.npmjs.org/ | ||