-
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