有学有练才叫学习:学而不思则罔,思而不学则殆:学而不习,纸上谈兵,习而不进,画地为牢!

npm 怎么发布自己的包?三步搞定(发布包教程)

开发者资讯 炮渣日记 3周前 (11-07) 20次浏览 已收录 0个评论 扫描二维码

1.构建发包项目

npm init -y
npm 怎么发布自己的包?三步搞定(发布包教程)

npm发包 package.json 配置示例

注意 package.json 中协议配置,src下添加LICENSE文件(内容示例见文末)。

2.注册npmjs账号(
https://www.npmjs.com/signup)

3.进入发包项目根路径,执行“npm login”,提示输入用户名、密码,然后会有邮箱验证码,完事后执行“npm publish”即可。

发布成功后,在npmjs的Packages下可以看到发布结果。

npm 怎么发布自己的包?三步搞定(发布包教程)

npmjs查看发包结果

LICENSE示例

The MIT License (MIT)

Copyright (c) 2022 haotiao

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

喜欢 (0)
炮渣日记
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址