创建发布npm包

1.在npm官网注册账号
2.切换npm源

npm config set registry https://registry.npmjs.org/

3.打开cmd并cd到要发布的项目目录,登录

npm login
//需要输入用户名,密码,邮箱

4.配置基础信息

 npm init

5.配置信息如下

{
  "name": "test123456",//name是npm包的名称
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

6.新建index.js

module.exports = function() {
    console.log('哈喽,这是一个npm包测试')
}

7.发布

npm publish

8.删除已发布的包

npm --force unpublish test123456
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容