NPM 常用命令

NPM提供了很多命令,例如install和publish,使用npm help可查看所有命令。

NPM提供了很多命令,例如install和publish,使用npm help可查看所有命令。

$ npm help
npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term> (in a browser)
npm help npm       more involved overview (in a browser)

All commands:

access, adduser,audit,bugs,cache,ci,completion,config, dedupe, deprecate, diff, dist-tag, docs, doctor,edit, exec, explain, explore, find-dupes, fund, get, help,hook, init, install, install-ci-test, install-test, link,ll, login, logout, ls, org, outdated, owner, pack, ping,pkg, prefix, profile, prune, publish, query, rebuild, repo,restart, root, run-script, search, set, shrinkwrap, star,stars, start, stop, team, test, token, uninstall, unpublish,unstar, update, version, view, whoami

使用npm help 可查看某条命令的详细帮助,例如npm help install。

在package.json所在目录下使用npm install . -g可先在本地安装当前命令行程序,可用于发布前的本地测试。

使用npm update 可以把当前目录下node_modules子目录里边的对应模块更新至最新版本。

使用npm update -g可以把全局安装的对应命令行程序更新至最新版。

使用npm cache clear可以清空NPM本地缓存,用于对付使用相同版本号发布新版本代码的人。

使用npm unpublish @可以撤销发布自己发布过的某个版本代码。

 

posted @ 2024-03-08 15:18  joshua317  阅读(7)  评论(0编辑  收藏  举报