为了迎合蛋疼的业务需求, 写了一个修改本地localhost的grunt插件, 具体内容见

说一下发布到官网npm库的流程

官方的npm注册地址是: http://registry.npmjs.org/

首先访问http://www.npmjs.org, 注册一个你自己的账号。

然后在本地命令行中: npm adduser 把刚刚注册的账号根据命令行提示, 添加进去。

如果项目已经在github提交,接下来就非常方便了,这也是我推荐的方式:

所有github的项目都可以通过地址 https://github.com/materliu/grunt-localhosts/tarball/master 将你的项目master打包下载

注意修改 materliu/grunt-localhosts 为你的项目名

而npm publish 支持直接通过 项目的tar gz包地址 publish

命令: npm publish [--tag ]

npm publish https://codeload.github.com/materliu/grunt-localhosts/legacy.tar.gz/master –tag 0.0.1

后边 –tag 指定你要覆盖的版本, 不跟的话就是覆盖最新版

如果项目没有在github提交,publish命令为:npm publish [--tag ]

简单的方式 直接进入当前 npm modules 项目所在目录 npm publish 搞定

注意点: 没有必要把你的npm用到的node_modules也上传到你的github上, 最后用户安装你的npm的时候, 是根据你的package.json文件中的 dependencies 里边指定的项来自动帮你安装的, 而不是根据你github里边上传了什么node_modules来的。