-
npm init : 创建一个package.json文件,包括名称、版本、作者等信息;
-
npm install <name> : 安装nodejs的依赖包;
-
npm install <name> -g : 将包安装到全局环境中;
-
npm install <name> --save : 安装的同时,将包的信息写入package.json中;
-
npm remove <name> : 移除包;
-
npm update <name> : 更新包;
-
npm ls : 查看当前安装的所有包;
-
npm root : 查看当前包的安装路径;
-
npm root -g : 查看全局安装包的路径;
-
npm help <topic> : 在默认浏览器中打开指定命令的文档页面,如果topic为空,则列出npm的所有命令;
>npm help
Usage: npm <command>
where <command> is one of:
add-user, adduser, apihelp, author, bin, bugs, c, cache,
completion, config, ddp, dedupe, deprecate, docs, edit,
explore, faq, find, find-dupes, get, help, help-search,
home, i, info, init, install, isntall, issues, la, link,
list, ll, ln, login, ls, outdated, owner, pack, prefix,
prune, publish, r, rb, rebuild, remove, repo, restart, rm,
root, run-script, s, se, search, set, show, shrinkwrap,
star, stars, start, stop, submodule, tag, test, tst, un,
uninstall, unlink, unpublish, unstar, up, update, version,
view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm faq commonly asked questions
npm help <term> search for help on <term>
npm help npm involved overview