[英]Install error with lerna and yarn workspace
I implemented Lerna and yarn workspaces in my project and when I gonna install packages, it says我在我的项目中实现了 Lerna 和纱线工作区,当我要安装包时,它说
error Couldn't find package "@kratos/core@^1.0.1" required by "@kratos/storybook@1.0.1" on the "npm" registry.
Whereas these @kratos/core
and @kratos/storybook
packages exist in the packages folder and they are local packages.而这些
@kratos/core
和@kratos/storybook
包存在于 packages 文件夹中,它们是本地包。
I tried these commands but facing the below error:我尝试了这些命令但遇到以下错误:
lerna notice cli v3.22.0
lerna info versioning independent
lerna notice filter including "@kratos/renderer"
lerna info filter [ '@kratos/renderer' ]
lerna WARN No packages found where @kratos/core can be added.
Lerna config file:勒纳配置文件:
{
"useWorkspaces": true,
"npmClient": "yarn",
"packages": ["packages/*"],
"version": "independent",
"command": {
"publish": {
"ignoreChanges": [
"test/**/*",
"*.test.*",
"*.spec.*",
"cypress",
"*.md",
"scripts",
"lib",
"tslint.json",
"tsconfig.json"
]
},
"run": {
"npmClient": "yarn"
}
}
}
Thanks, Lerna for having a lot of problems without useful documentation.谢谢,Lerna 在没有有用文档的情况下遇到了很多问题。
You need to run lerna bootstrap
in order for lerna to create symbolic links for all of your packages/*
in node_modules.您需要运行
lerna bootstrap
以便 lerna 为 node_modules 中的所有packages/*
创建符号链接。
If your local version of any of your packages, in your case @kratos/core
, does not match the version you are referencing in your package.json files, then it will try to import the package from npm. If your local version of any of your packages, in your case
@kratos/core
, does not match the version you are referencing in your package.json files, then it will try to import the package from npm. This could be why you are seeing "could not find package on the npm registry"这可能就是您看到“在 npm 注册表上找不到 package”的原因
I ran into this same issue but it was caused by something else.我遇到了同样的问题,但它是由其他原因引起的。 In my scenario, I was trying to link a package like so:
在我的场景中,我试图像这样链接 package:
// package B
"dependencies": {
"@scope/packageA": "*",
}
but Package A had a package.json with version specified as "0.x.0-alpha.1" which was causing Lerna to return a similar error:但是 Package A 有一个 package.json 版本指定为“0.x.0-alpha.1”,这导致 Lerna 返回类似的错误:
"error Couldn't find any versions for "@scope/packageA" that matches "*""
“错误找不到与“*”匹配的“@scope/packageA”的任何版本
Solution: Package A for us turned out to not be published to our NPM registry under any non-pre-release version.解决方案: Package A for us 竟然没有在任何非预发布版本下发布到我们的 NPM 注册表。 So, the solution was to revert the version string of Package A to be just, "0.x.0" (removed "-alpha.1" prefix) and then re-ran the
lerna bootstrap
command, and it worked!因此,解决方案是将 Package A 的版本字符串还原为“0.x.0”(删除“-alpha.1”前缀),然后重新运行
lerna bootstrap
命令,它成功了!
Hope this helps:)希望这可以帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.