npm 发包小记
发包过程
首先要有个账号,到 npm 官网上注册即可。
添加用户
~ npm adduser
Username:
Password:
Email:
登录
~ npm login
Username:
Password:
Emial:
发布
~ npm publish
取消发布
~ npm unpublish
私服
~ npm adduser --registry http[s]://demo.com
~ npm login --registry http[s]://demo.com
~ npm publish --registry http[s]://demo.com
~ npm unpublish --registry http[s]://demo.com
package.json 文件
{
"name": "@zebra/xxx",
"version": "0.0.1",
"description": "项目描述",
"author": "baskwind <baskwind@163.com>",
"bugs": {
"url": "https://demo.com/path/to/repo/issues"
},
"homepage": "https://demo.com/path/to/demo",
"keywords": [
"keywords",
"keywords"
],
"repository": {
"type": "git",
"url": "https://demo.com/path/to/repo"
},
"license": "MIT",
"main": "path/to/index.js",
"module": "path/to/index.mjs",
"types": "path/to/index.d.ts"
}
一般通过 npm init
即可生成。
license MIT 的模板
Copyright (C) <year> <copyright holders>
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.
使用时,只需要把 <year> <copyright holders>
换成相应内容即可。
更多许可证:wiki 传送门
README
- 可以使用 shields.io 生成小图标使用。
CDN
- jsdelivr
CommonJS
CMD
AMD
ESM
模块都支持- https://cdn.jsdelivr.net/npm/package@version/file
- https://esm.run/package@version/file
- https://cdn.jsdelivr.net/gh/user/repo@version/file
- unpkg.com
npm
镜像- https://unpkg.com/package@version/file
- esm.sh 纯
ESM
模块- import xxx from "https://esm.sh/package@version/file"
- import xxx from "https://esm.sh/gh/user/repo@version/file";
- bootcdn.cn 国内
npm
镜像- 搜索使用