[英]Couldn't find package “my-custom-package” on the “npm” registry
I have a Node.js project separated in several custom packages, each having their own package.json
file. 我有一个Node.js项目,该项目分为几个自定义程序包,每个程序包都有自己的
package.json
文件。 This is all custom code for that specific project. 这是该特定项目的所有自定义代码。 Some have
dependencies/devDependencies
, and when running 有些具有
dependencies/devDependencies
,并且在运行时
yarn install
all dependencies are installed and everything goes smoothly. 安装所有依赖项,一切顺利。
The content of the package.json files are as follows: package.json文件的内容如下:
{
"name": "my-custom-package-name", // This changes in each package.json file
"version": "1.0.3-beta.1", // The version is the same in all package.json files
"private": true,
"repository": "https://github.com/my-organization/my-private-repo",
[...]
}
Now I am asked to do a new deployment of the project to production and to increment the version number of the packages for the new release. 现在,我被要求将项目重新部署到生产中,并增加新版本的软件包的版本号。 So I change the version number in each
package.json
file by removing the prerelease tag to: 因此,我通过删除prerelease标签更改为每个
package.json
文件中的版本号:
"version": "1.0.3.1"
But then, if I run yarn install
again, for each package where the prerelease tag was removed from the version number of the custom package, I get an error like this: 但是,然后,如果我再次运行
yarn install
,对于从自定义程序包的版本号中删除了预发行标签的每个程序包,都会收到如下错误:
yarn install v1.3.2
[1/4] Resolving packages...
error Couldn't find package "my-custom-package-name" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Why is this happening when the prerelease tag is removed? 为何删除预发行标签会发生这种情况? Why is this not happening when the prerelease tag is there?
当预发布标签在那里时,为什么不发生这种情况?
Those packages are not being used as dependencies for any other package of the project, so why is yarn trying to resolve a package on npm that matches the name and version of the package.json files? 这些软件包没有被用作项目的其他任何软件包的依赖项,那么为什么yarn试图在npm上解析与package.json文件的名称和版本相匹配的软件包?
I really looked around on the Web trying to find answers relating to this, but could not find anything relevant. 我真的在网上四处张望,试图找到与此有关的答案,但是找不到任何相关的东西。
I found the answer to my problem and the reason is that by removing the "-beta" from the version number, the version number no longers complies with sematinc versioning. 我找到了解决问题的答案,原因是通过从版本号中删除“ -beta”,该版本号不再符合sematinc版本。 See this other SO question here:
在这里看到另一个SO问题:
npm: Why is a version "0.1" invalid? npm:为什么版本“ 0.1”无效?
In other words, version number must be 3 numbers separated by dots, and after that a dash can be put with a prerelease tag or a build number. 换句话说,版本号必须是3个数字,并用点号分隔,之后可以在破折号前加上预发行标签或内部版本号。 But having a version number composed of 4 digits separated by dots is not a valid version number according to semver.org.
但是,根据semver.org,具有由4个数字组成且由点分隔的版本号不是有效的版本号。
So for some reason, instead of complaining of an illegally formatted version number for my package, "error Couldn't find package" is what yarn outputs. 因此,出于某种原因,而不是抱怨我的包装的格式格式版本非法,而是纱线输出“错误找不到包装”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.