-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
概述
既然经常用到NPM指令,而又经常会记不住一些常用的指令。
索性一次性整理它们,纳入知识宫殿里面。
常用的指令系
用户相关:
1. npm adduser
2. npm logout
3. npm whoami
配置相关:
1. npm config
2. npm get
3. npm set
项目相关:
1. npm init
2. npm rebuild
安装 / 更新 / 卸载包:
1. npm install [--save | --save-dev]
2. npm update
3. npm uninstall
管理包:
1. npm dedupe
2. npm outdated
3. npm prune
运行脚本:
1. npm run-script
3. npm test
2. npm start
3. npm restart
4. npm stop
发布 / 取消包:
1. publish
2. unpublish
查看发布的包:
1. npm bugs
2. npm docs
2. npm repo
3. npm view
所有指令简介
access,设置已发布的包的访问级别
npm access public [<package>]
npm access restricted [<package>]
npm access grant <read-only|read-write> <scope:team> [<package>]
npm access revoke <scope:team> [<package>]
npm access ls-packages [<user>|<scope>|<scope:team>]
npm access ls-collaborators [<package> [<user>]]
npm access edit [<package>]
adduser,注册npm用户
npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy] [--always-auth]
aliases: login, add-user
bin,打印出在当前文件夹下,npm将会在哪里安装可执行文件
npm bin [--global]
bugs,将会用浏览器打开package.json中配置的bugs.url参数,没有则打开包在npm官网上的url路径
npm bugs [<pkgname>]
alias: issues
cache,添加、列举、清除npm缓存文件夹
npm cache add <tarball file>
npm cache add <folder>
npm cache add <tarball url>
npm cache add <git url>
npm cache add <name>@<version>
npm cache clean
npm cache verify
ci
npm ci
completion,npm tab命令补全
source <(npm completion)
config,管理npm配置文件
npm config set <key> <value>
npm config get [<key>]
npm config delete <key>
npm config list [--json]
npm config edit
npm set <key> <value>
npm get [<key>]
alias: c
dedupe,删除重复包。搜索本地包树,并试图通过移动依赖关系进一步简化整体结果,使它们可以更有效地共享多个依赖包。
npm dedupe
aliases: ddp, find-dupes
deprecate,更新 npm 注册表中指定包所对应的数据条目, 为尝试安装它的所有人提示版本作废的警告信息。
npm deprecate <pkg>[@<version>] <message>
dist-tag,标签
npm dist-tag add <pkg>@<version> [<tag>]
npm dist-tag rm <pkg> <tag>
npm dist-tag ls [<pkg>]
alias: dist-tags
docs,用浏览器打开npm docs
npm docs <pkgname>
npm docs .
alias: home
doctor
npm doctor
edit,编辑已安装包
npm edit <pkg>[@<version>]
explore
npm explore <pkg> [ -- <command>]
get
npm get <key> <value> (See `npm config`)
help
help-search
npm help-search <text>
init,初始化一个package.json文档
npm init [--force|-f|--yes|-y]
install,安装包
npm install (with no args, in package dir)
npm install [<@scope>/]<pkg>
npm install [<@scope>/]<pkg>@<tag>
npm install [<@scope>/]<pkg>@<version>
npm install [<@scope>/]<pkg>@<version range>
npm install <folder>
npm install <tarball file>
npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>
aliases: i, isntall, add
common options: [--save|--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]
install-test,允许npm install后紧接允许npm test
npm install-test [args]
Same args as `npm install`
alias: it
link,为npm包创建链接
npm link (in package dir)
npm link [<@scope>/]<pkg>[@<version>]
alias: ln
logout, 登出npm registry
npm logout [--registry=<url>] [--scope=<@scope>]
ls,列出已安装的包,包括它们的依赖
npm ls [[<@scope>/]<pkg> ...]
aliases: list, la, ll
outdated,列出当前已经不是最新版本的包
npm outdated [[<@scope>/]<pkg> ...]
owner,管理(添加、删除、列出)包所属的用户(列表)
npm owner add <user> [<@scope>/]<pkg>
npm owner rm <user> [<@scope>/]<pkg>
npm owner ls [<@scope>/]<pkg>
alias: author
pack,针对包创建一个压缩包
npm pack [[<@scope>/]<pkg>...]
ping
npm ping
ping registry
prefix,打印本地或全局的包路径前缀
npm prefix [-g]
profile
npm profile enable-2fa [auth-only|auth-and-writes]
npm profile disable-2fa
npm profile get [<key>]
npm profile set <key> <value>
prune,删除多余的包(不包括父包的依赖)
npm prune [[<@scope>/]<pkg>...] [--production]
publish,发布npm包
npm publish [<tarball>|<folder>] [--tag <tag>] [--access <public|restricted>]
Publishes '.' if no argument supplied
Sets tag `latest` if no --tag specified
rebuild,在运行了npm build后的文件夹运行,当你安装了一个新的node版本,则必须重新编译所有的C++插件与新的二进制
npm rebuild [[<@scope>/<name>]...]
alias: rb
repo, 在浏览器中打开包仓库页repository
npm repo [<pkg>]
restart
npm restart [-- <args>]
root,打印npm包存储目录
npm root [-g]
run-script,运行已经在package.json里注册过的指令
npm run-script <command> [-- <args>...]
aliases: run, rum
search,搜索包
npm search [--long] [search terms ...]
aliases: s, se, find
set
npm set <key> <value> (See `npm config`)
shrinkwrap,锁定依赖版本
npm shrinkwrap
star,
npm star [<pkg>...]
npm unstar [<pkg>...]
alias: unstar
stars
npm stars [<user>]
start,运行package.json scripts配置的start命令
npm start [-- <args>]
stop,运行package.json scripts配置的stop命令
npm stop [-- <args>]
team
npm team create <scope:team>
npm team destroy <scope:team>
npm team add <scope:team> <user>
npm team rm <scope:team> <user>
npm team ls <scope>|<scope:team>
npm team edit <scope:team>
test,运行package.json scripts配置的test命令
npm test [-- <args>]
aliases: tst, t
token
npm token list
npm token revoke <tokenKey>
npm token create [--read-only] [--cidr=list]
uninstall,卸载包
npm uninstall [<@scope>/]<pkg>[@<version>]... [--save-prod|--save-dev|--save-optional] [--no-save]
aliases: un, unlink, remove, rm, r
unpublish,从registry移除一个包
npm unpublish [<@scope>/]<pkg>[@<version>]
update,更新包
npm update [-g] [<pkg>...]
aliases: up, upgrade, udpate
version
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
(run in package dir)
'npm -v' or 'npm --version' to print npm version (5.7.1)
'npm view <pkg> version' to view a package's published version
'npm ls' to inspect current package/dependency versions
view,在npm registry上查看包的信息
npm view [<@scope>/]<pkg>[@<version>] [<field>[.subfield]...]
aliases: v, info, show
whoami,显示当前登录npm的用户信息
npm whoami [--registry <registry>]
(just prints username according to given registry)
参考
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels