繁体   English   中英

lerna 和 yarn workspace 安装错误

[英]Install error with lerna and yarn workspace

我在我的项目中实现了 Lerna 和纱线工作区,当我要安装包时,它说

error Couldn't find package "@kratos/core@^1.0.1" required by "@kratos/storybook@1.0.1" on the "npm" registry.

而这些@kratos/core@kratos/storybook包存在于 packages 文件夹中,它们是本地包。

我尝试了这些命令但遇到以下错误:

  • lerna 添加@kratos/core --scope @kratos/renderer:
  • lerna 添加@kratos/核心包/渲染器
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. 

勒纳配置文件:

{
    "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"
        }
    }
}

谢谢,Lerna 在没有有用文档的情况下遇到了很多问题。

  1. 您需要运行lerna bootstrap以便 lerna 为 node_modules 中的所有packages/*创建符号链接。

  2. 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. 这可能就是您看到“在 npm 注册表上找不到 package”的原因

我遇到了同样的问题,但它是由其他原因引起的。 在我的场景中,我试图像这样链接 package:

// package B

"dependencies": {
  "@scope/packageA": "*",
}

但是 Package A 有一个 package.json 版本指定为“0.x.0-alpha.1”,这导致 Lerna 返回类似的错误:

“错误找不到与“*”匹配的“@scope/packageA”的任何版本

解决方案: Package A for us 竟然没有在任何非预发布版本下发布到我们的 NPM 注册表。 因此,解决方案是将 Package A 的版本字符串还原为“0.x.0”(删除“-alpha.1”前缀),然后重新运行lerna bootstrap命令,它成功了!

希望这可以帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM