Skip to content
On this page

npm init 用来初始化生成一个新的 package.json 文件。输入 npm init 并且根据对应的提示回答问题,会向用户提 问一系列问题,如果你觉得不用修改默认配置,一路回车就可以了。 如果使用了 -f (代表 force )、 -y (代表 yes ),则跳过提问阶段,直接生成一个新的 package.json 文件。

shell
// npm设置新淘宝源
npm config set registry https://registry.npmmirror.com
// npm设置回本源
npm config set registry https://registry.npmjs.org

npm set:设置环境变量,例如: npm set init-author-name 'Your name' ,初始化的时候会使用默认环境变量; npm info:查看某个包的信息,例如: npm info lodashnpm search:查找 npm 仓库,后面可以跟字符串或者正则表达式,例如: npm search webpacknpm list:树形的展现当前项目安装的所有模块,以及对应的依赖,例如: npm list --global 查看全局安装的模块。 npm cache clean --force:清理缓存命令。

Released under the MIT License.