日常开发过程中经常用到一些别人开源的轮子,但是有些项目可能因为作者太忙,后续基本不会有更新,但是自己又需要对项目进行定制开发,所以这个时候就需要修改源码,然后自己发布npm包
fork并clone仓库到本地
在本地修改源码
修改package.json
{
"name": "@kerin/sudo-prompt",
"version": "9.2.2",
"description": "Run a command using sudo, prompting the user with an OS dialog if necessary",
"main": "index.js",
"types": "index.d.ts",
"files": [
"LICENSE",
"README.md",
"index.d.ts",
"index.js",
"package.json",
"test.js",
"test-concurrent.js"
],
"repository": {
"type": "git",
"url": "git+https://github.com/Kerinlin/sudo-prompt.git"
},
"keywords": [
"sudo",
"os",
"dialog",
"prompt",
"command",
"exec",
"user access control",
"UAC",
"privileges",
"administrative",
"elevate",
"run as administrator"
],
"author": "Kerinlin",
"license": "MIT",
"bugs": {
"url": "<https://github.com/Kerinlin/sudo-prompt/issues>"
},
"homepage": "<https://github.com/Kerinlin/sudo-prompt#readme>",
"scripts": {}
}
如果没有npm账号,需要去npm注册账号
终端登录npm
npm login
登录后输入命令发布
npm publish