npm模块使用(初级)

npm是什么

npm是Node的模块管理器,全称Node Package Manager即node包管理器

npm的配置

npm config set loglevel http
让你知道npm发的每一个请求
npm config set progress false
关闭进度条,貌似可提高安装速度。
npm config set registry https://registry.npm.taobao.org/
使用国内路径,不用npm公司提供的源,用npm下载模块时可以大大提高下载速度。
npm config delete registry
恢复原样,因为在发布一个模块时,需要用npm模块,此字符串可用alias设置快捷键。

如何安装一个模块

1
2
npm install xxx 本地安装
npm install -g xxx 全局安装

如何卸载一个模块

1
2
npm uninstall --force xxx
npm uninstall -g --force xxx

如何推送一个模块

npm adduser
运行该字符串时,按提示输入你的npm用户名,密码,和注册邮箱。
npm init
运行该命令,会提示你输入相关信息:模块名称,版本号,作者等等(其余可不用填写)。此时会创建一个文件pack.json,里面用来记录模块的相关信息。
npm publish
推送完成
npm unpublish --force xxx
取消推送的模块