changesets 在 github 工作流并发发包时出现 E404 错误
错误情况
在工作流发包时,出现莫名其妙的 E404 错误,称查找包失败。让人很疑惑,查找不到包为什么还会自动失败呢?
E404
log
Run pnpm changeset publish --otp=***
pnpm changeset publish --otp=***
shell: /usr/bin/bash -e {0}
env:
PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
NODE_AUTH_TOKEN: XXXXX-XXXXX-XXXXX-XXXXX
🦋 info npm info @ruan-cat/commitlint-config
🦋 info npm info @ruan-cat/domains
🦋 info npm info @ruan-cat/generate-code-workspace
🦋 info npm info @ruan-cat/utils
🦋 info npm info @ruan-cat/vercel-deploy-tool
🦋 info npm info @ruan-cat/vuepress-preset-config
🦋 info @ruan-cat/commitlint-config is being published because our local version (0.1.4) has not been published on npm
🦋 info @ruan-cat/domains is being published because our local version (0.1.4) has not been published on npm
🦋 warn @ruan-cat/generate-code-workspace is not being published because version 0.2.3 is already published on npm
🦋 info @ruan-cat/utils is being published because our local version (1.4.2) has not been published on npm
🦋 info @ruan-cat/vercel-deploy-tool is being published because our local version (0.5.9) has not been published on npm
🦋 info @ruan-cat/vuepress-preset-config is being published because our local version (0.1.19) has not been published on npm
🦋 info Publishing "@ruan-cat/commitlint-config" at "0.1.4"
🦋 info Publishing "@ruan-cat/domains" at "0.1.4"
🦋 info Publishing "@ruan-cat/utils" at "1.4.2"
🦋 info Publishing "@ruan-cat/vercel-deploy-tool" at "0.5.9"
🦋 info Publishing "@ruan-cat/vuepress-preset-config" at "0.1.19"
🦋 error an error occurred while publishing @ruan-cat/commitlint-config: E404 Not Found - PUT https://registry.npmjs.org/@ruan-cat%2fcommitlint-config - Not found
🦋 error '@ruan-cat/commitlint-config@0.1.4' is not in this registry.
🦋 error
🦋 error Note that you can also install from a
🦋 error tarball, folder, http url, or git url.
🦋 error npm notice Publishing to https://registry.npmjs.org/ with tag latest and public access
🦋 error npm error code E404
🦋 error npm error 404 Not Found - PUT https://registry.npmjs.org/@ruan-cat%2fcommitlint-config - Not found
🦋 error npm error 404
🦋 error npm error 404 '@ruan-cat/commitlint-config@0.1.4' is not in this registry.
🦋 error npm error 404
🦋 error npm error 404 Note that you can also install from a
🦋 error npm error 404 tarball, folder, http url, or git url.
🦋 error npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2025-02-07T14_42_32_030Z-debug-0.log
解决方案
不知道原理,我主动声明清楚特定名称的环境变量后,就可以正常完成并发发包了。
即 NODE_AUTH_TOKEN 。
主动增加 NODE_AUTH_TOKEN
yaml
- name: 发包
run: pnpm changeset publish --otp=${{ secrets.NPM_TOKEN }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
成功执行的日志
log
Run pnpm changeset publish --otp=***
pnpm changeset publish --otp=***
shell: /usr/bin/bash -e {0}
env:
PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
NODE_AUTH_TOKEN: ***
🦋 info npm info @ruan-cat/commitlint-config
🦋 info npm info @ruan-cat/domains
🦋 info npm info @ruan-cat/generate-code-workspace
🦋 info npm info @ruan-cat/utils
🦋 info npm info @ruan-cat/vercel-deploy-tool
🦋 info npm info @ruan-cat/vuepress-preset-config
🦋 info @ruan-cat/commitlint-config is being published because our local version (0.1.4) has not been published on npm
🦋 info @ruan-cat/domains is being published because our local version (0.1.4) has not been published on npm
🦋 warn @ruan-cat/generate-code-workspace is not being published because version 0.2.3 is already published on npm
🦋 info @ruan-cat/utils is being published because our local version (1.4.2) has not been published on npm
🦋 info @ruan-cat/vercel-deploy-tool is being published because our local version (0.5.9) has not been published on npm
🦋 info @ruan-cat/vuepress-preset-config is being published because our local version (0.1.19) has not been published on npm
🦋 info Publishing "@ruan-cat/commitlint-config" at "0.1.4"
🦋 info Publishing "@ruan-cat/domains" at "0.1.4"
🦋 info Publishing "@ruan-cat/utils" at "1.4.2"
🦋 info Publishing "@ruan-cat/vercel-deploy-tool" at "0.5.9"
🦋 info Publishing "@ruan-cat/vuepress-preset-config" at "0.1.19"
🦋 success packages published successfully:
🦋 @ruan-cat/commitlint-config@0.1.4
🦋 @ruan-cat/domains@0.1.4
🦋 @ruan-cat/utils@1.4.2
🦋 @ruan-cat/vercel-deploy-tool@0.5.9
🦋 @ruan-cat/vuepress-preset-config@0.1.19
🦋 Creating git tags...
🦋 New tag: @ruan-cat/commitlint-config@0.1.4
🦋 New tag: @ruan-cat/domains@0.1.4
🦋 New tag: @ruan-cat/utils@1.4.2
🦋 New tag: @ruan-cat/vercel-deploy-tool@0.5.9
🦋 New tag: @ruan-cat/vuepress-preset-config@0.1.19
可能的注意事项
工作流文件几乎必不可少的 actions/setup-node 工作流,称会主动阅读环境变量 env.NODE_AUTH_TOKEN 。故考虑主动声明该名称的环境变量。