npm命令

1.升级全局变量:

ncu -g
// 或者
npm outdated -g

2.更新n管理包:

curl -0 -L https://npmjs.org/install.sh | sudo sh

3.npm包发布

# 注册新账号
npm adduser
# 登陆用户
npm login
# 查找user config文件
npm config ls -l|grep config
# 发布包
npm publish <folder>
# 安装包
npm install <package-name>
# 查看管理包的所有者
npm owner ls <package-name>
# 添加/删除包的所有者
npm owner add <user> <package-name>
npm ower rm <user> <package-name>
# 分析包
npm ls
# 更新包版本
npm version patch 

4.【unscoped packages cannot be private : webpack-api-mocker-pro】的问题解决:

npm publish --access public

  问题链接:https://stackoverflow.com/questions/53420758/npm-publish-gives-unscoped-packages-cannot-be-private

5.检测是否包含某个包

npm ls event-stream flatmap-stream
# or
yarn why flatmap-stream

6.查看安装的包

# 查看所有高级的npm moudles
npm list --depth=0
# 查看全局的npm包
npm list --depth=0 -global

7.修复npm依赖中的漏洞,并安装有相关的更新

# 检测依赖中漏洞
npm audit
# 更新有更新的漏洞
npm audit fix
# 只更新package-lock.json,不更新node_modules
npm audit fix --package-lock-only
# 只更新dependencies中依赖的包,跳过devDependencies的包
npm audit fix --only=prod
# 得到`audit fix`以json输出的更新信息,不真正更新
npm audit fix --dry-run --json
# 以json格式输出检测内容
npm audit --json

8.node安装

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
nvm install 10.13.0
nvm use 10.13.0
原文地址:https://www.cnblogs.com/muzi131313/p/7283979.html