发布npm包

1,注册一个npm账号
2,生成一个package.json文件
npm init 或者 npm init --yes
name: 必须是小写字母和一个单词,可以使用连接符和下划线
version: 字段的格式必须为x.x.x,并遵循语义版本控制准则。
author: 可以使用有效或者网址 Your Name <email@example.com> (http://example.com)
3,为init命令设置配置选项
> npm set init-author-email "example-user@example.com"
> npm set init-author-name "example_user"
> npm set init-license "MIT"
4,创建Node.js模块 : node.js 模块是一种能被发布到npm的包
5,npm publish --access=public
6,如果报错就需要登录 npm login
7,然后就可以下载安装了 npm i design-patten-demo

8,定义 repository属性

// package.json
{
  "repository": {
    "type": "git",
    "url": "http://github.com/yourname/repositoryname.git"
  }
}

 

posted @ 2022-09-06 09:38  jqynr  阅读(23)  评论(0)    收藏  举报