Cha*_*aye 7 node.js npm npm-publish github-actions github-package-registry
我尝试实现使用 GitHub Actions 发布和安装包的官方指南:使用细化权限验证包注册表
失败:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)
包.json
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)
.github/workflow/ci.yml
{
"name": "@charneykaye/banana",
"version": "4.0.6",
"repository": "git@github.com:charneykaye/banana",
"description": "made by artists in a new algorithmic medium",
"bin": {
"banana": "./lib/index.js"
},
"author": "Charney Kaye <charney@xj.io>",
"license": "MIT",
"scripts": {
"start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts",
"start:windows": "nodemon --watch 'src/**/*.ts' --exec \"npx ts-node\" src/index.ts",
"create": "npm run build && npm run test",
"banana": "npx ts-node ./src/index.ts",
"test": "tsc -p . && jest --coverage --verbose --runInBand"
},
"dependencies": {
"commander": "^10.0.0",
"figlet": "^1.5.2",
"octokit": "^1.8.0"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.4.1",
"@types/jest": "^29.4.0",
"@types/node": "^18.11.18",
"babel-jest": "^29.4.1",
"jest": "^29.4.1",
"nodemon": "^2.0.20",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testMatch": [
"**/__tests__/**test.ts",
"**/__tests__/**test.tsx"
]
}
}
Run Code Online (Sandbox Code Playgroud)
.npmrc
@charneykaye:registry=https://npm.pkg.github.com
Run Code Online (Sandbox Code Playgroud)
需要再连接两个点才能将令牌一直连接到npm publish
将.npmrc替换为
//npm.pkg.github.com/:_authToken=${NPM_CONFIG_TOKEN}
@charneykaye:registry=https://npm.pkg.github.com
always-auth=true
Run Code Online (Sandbox Code Playgroud)
以及.github/workflow/ci.yml中的最后一个操作
//npm.pkg.github.com/:_authToken=${NPM_CONFIG_TOKEN}
@charneykaye:registry=https://npm.pkg.github.com
always-auth=true
Run Code Online (Sandbox Code Playgroud)