美文网首页
npm打包教程

npm打包教程

作者: 7c1fb13ff46d | 来源:发表于2017-03-26 21:26 被阅读0次

    Npm打包

    1.上官网注册一个npm账号(官网:http://npmjs.org

    2.使用module.exports方式定义模块food.js:

    并在example.js中使用food.js:

    3.接下来在控制台输入:npm init,填写相关的package.json信息:

    4.添加相关npm用户信息:

    5.最后发布制作的npm模块,输入命令npm publish。

    问题1:

    npm ERR! you do not have permissionto publish "your module name". Are you logged in as the correct user?

    Key:

    url:https://github.com/npm/npm/issues/9874

    应该是上传的npm包名已被使用,在此将food_taste更改为food_taste_170320,加个时间戳再次打包上传。

    问题2:如果在之前使用了淘宝镜像,会引起这个问题:npm ERR! no_perms Private mode enable, only admin can publish this

    module。

    Key:这里注意的是因为国内网络问题,许多小伙伴把npm的镜像代理到淘宝或者别的地方了,这里要设置回原来的镜像。

    npmconfig set registry=http://registry.npmjs.org

    6.然后上官网https://www.npmjs.com/,查看你的profile,就会看到成功上传的包:

    相关文章

      网友评论

          本文标题:npm打包教程

          本文链接:https://www.haomeiwen.com/subject/vejbnttx.html