正文
登录
去 npm 官网整一个账号。
先更新一下:
npm install -g npm@latest把镜像站关了:
npm config set registry https://registry.npmjs.org/尝试登陆:
npm initnpm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/XXX
Press ENTER to open in the browser...
在浏览器中登录后,完成。
项目工程
做好项目工程,在 github 上整一个仓库:GZ-Metal-Cell/hexo-theme-quieter: 🍓 A simple and fully functional Hexo theme, improved based on Hexo theme quiet.
创建包
在项目工程文件夹下使用 npm init -y 来自动生成一个默认的 package.json 文件。
一阵操作:
{
"name": "hexo-theme-quieter",
"version": "1.0.0",
"description": "🍓A simple and fully functional Hexo theme, improved based on Hexo theme quiet.",
"main": "package.json",
"scripts": {
"test": "echo test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GZ-Metal-Cell/hexo-theme-quieter.git"
},
"keywords": [
"hexo",
"hexo-theme",
"theme",
"quieter",
"simple"
],
"author": "Gz-Metal-Cell",
"license": "MIT",
"bugs": {
"url": "https://github.com/GZ-Metal-Cell/hexo-theme-quieter/issues"
},
"homepage": "https://github.com/GZ-Metal-Cell/hexo-theme-quieter#readme",
"devDependencies": {
"hexo": "^6.1.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-less": "^4.0.0",
"crypto-js": "^4.2.0"
}
}发布包
npm publish发布后管理
- 可以通过 npm 官网 访问和管理你的包。
- 看看自己整的:hexo-theme-quieter - npm
- 若想更新版本,可以在代码更改后再次更新
package.json里的版本号,并使用npm publish发布新版本。- 如果你需要更新已发布的包,只需修改代码、更新版本号,然后再次执行
npm publish即可。请确保版本号与之前不同,否则 npm 会拒绝发布。
- 如果你需要更新已发布的包,只需修改代码、更新版本号,然后再次执行