「Node.js」- npm(包管理器) @20210215

在 Linux 中,安装 npm 工具

升级 NPM 命令:

npm install -g npm@next
npm install -g npm@latest

常用命令整理

# npm list -g # 显示所有用户目录中的包,以树形结构显示
# npm list -g -- depth=0 # 指定树显示的深度
# npm list # 显示当前目录中的包

常见问题汇总(FAQ)

npm 配置文件路径(.npmrc)

npm - Npmrc - w3resource

1)Per-user config file: $HOME/.npmrc
2)Global config file: $PREFIX/etc/npmrc

使用国内阿里云镜像加速

npm和yarn使用国内阿里云镜像加速 - mouseleo - 博客园

npm config set registry \
    https://registry.npm.taobao.org --global
npm config set disturl \
    https://npm.taobao.org/dist --global

设置使用网络加速

How to use NPM Behind a SOCKS Proxy | by James Jeffery | Medium

# 添加网络加速

npm config set proxy "http://127.0.0.1:8123"
npm config set https-proxy "http://127.0.0.1:8123"

# 删除网络加速

npm config delete proxy
npm config delete https-proxy

相关文章

「NVM」- Node Version Manager(在本地安装多版本 Node.js 环境)
「Node.js」- Yarn(Package Manager)

参考文献

npm tricks part 1: Get list of globally installed packages
Try the latest stable version of npm | npm Documentation


posted @ 2021-02-15 21:35  研究林纳斯写的  阅读(85)  评论(0编辑  收藏  举报