命令 | 描述 |
---|---|
npm init |
初始化一个新的Node.js项目 |
npm install [包名] |
安装指定包 |
npm install -g [包名] |
全局安装指定包 |
npm uninstall [包名] |
卸载指定包 |
npm update [包名] |
更新指定包 |
npm update -g [包名] |
全局更新指定包 |
npm list |
列出当前项目安装的包 |
npm list -g |
列出全局安装的包 |
npm search [关键词] |
搜索npm仓库中的包 |
npm info [包名] |
查看指定包的详细信息 |
npm run [脚本名] |
运行package.json中定义的脚本 |
npm start |
运行项目的启动脚本 |
npm test |
运行项目的测试脚本 |
npm audit |
检查项目依赖的安全性 |
npm audit fix |
自动修复安全漏洞 |
npm cache clean |
清理npm缓存 |
npm publish |
发布包到npm仓库 |
npm login |
登录到npm账户 |
npm logout |
退出npm账户 |