语义发布无法发布到 npm

Posted

技术标签:

【中文标题】语义发布无法发布到 npm【英文标题】:semantic-release fails to publish to npm 【发布时间】:2019-06-13 14:03:35 【问题描述】:

我正在使用语义发布 npm 模块来执行循环 ci 中的发布。我收到以下错误

[semantic-release] [@semantic-release/npm] › ℹ 将版本 1.0.0 写入 /home/circleci/tmp 中的 package.json npm 错误!版本没变,可能 想要--allow-same-version

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR! /home/circleci/.npm/_logs/2019-01-19T15_21_36_194Z-debug.log [3:21:36 PM] [语义发布] › ✖ 插件的“准备”步骤失败 “@semantic-release/npm”[下午 3:21:36] [语义发布] › ✖ 一个错误 运行语义发布时发生:错误:命令失败:npm 版本 1.0.0 --no-git-tag-version npm 错误!版本没变,可能 想要--allow-same-version

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR! /home/circleci/.npm/_logs/2019-01-19T15_21_36_194Z-debug.log

at makeError (/home/circleci/tmp/node_modules/execa/index.js:174:9)
at Promise.all.then.arr (/home/circleci/tmp/node_modules/execa/index.js:278:16)
at process._tickCallback (internal/process/next_tick.js:68:7)   code: 1,   stdout: '',   stderr:    'npm ERR! Version not changed,

可能需要--allow-same-version\n\nnpm ERR!本次运行的完整日志 可以在以下位置找到:\nnpm ERR! /home/circleci/.npm/_logs/2019-01-19T15_21_36_194Z-debug.log\n', 失败:true,信号:null,cmd:'npm 版本 1.0.0 --no-git-tag-version',timedOut:false,killed:false,pluginName:'@semantic-release/npm' 错误:命令失败:npm 版本 1.0.0 --no-git-tag-version npm 错误!版本没变,可能 想要--allow-same-version

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR! /home/circleci/.npm/_logs/2019-01-19T15_21_36_194Z-debug.log

at makeError (/home/circleci/tmp/node_modules/execa/index.js:174:9)
at Promise.all.then.arr (/home/circleci/tmp/node_modules/execa/index.js:278:16)
at process._tickCallback (internal/process/next_tick.js:68:7)   code: 1,   stdout: '',   stderr:    'npm ERR! Version not changed,

可能需要--allow-same-version\n\nnpm ERR!本次运行的完整日志 可以在以下位置找到:\nnpm ERR! /home/circleci/.npm/_logs/2019-01-19T15_21_36_194Z-debug.log\n', 失败:true,信号:null,cmd:'npm 版本 1.0.0 --no-git-tag-version', timedOut: false, kill: false, pluginName: '@semantic-release/npm' 退出代码1

我该如何解决这个问题?

【问题讨论】:

【参考方案1】:

此错误可能是因为您手动更新了package.json 中的版本。你应该让语义释放为你做这件事。

您应该将package.json 中的版本设置为0.0.0-dev。如果您想将更新后的 package.json 推送到您的仓库,请使用 @sematnic-release/git 插件。

【讨论】:

是的,这正是发生的事情。谢谢:)

以上是关于语义发布无法发布到 npm的主要内容,如果未能解决你的问题,请参考以下文章

发布到 npm 时无法在 Vue 中加载样式

无法从 GitHub Actions 发布到 npm:`<package> is not in the npm registry` 错误

无法从 Github 发布 npm 包?

人们无法使用 gomodules 使用我的 v2+ 语义版本控制版本

无法使用 NPM 更新到最新的打字稿

无法使用托管在 GPR 上的私有 NPM 包