简体   繁体   English

lerna 和 yarn workspace 安装错误

[英]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 add @kratos/core --scope @kratos/renderer: lerna 添加@kratos/core --scope @kratos/renderer:
  • lerna add @kratos/core packages/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. 

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 在没有有用文档的情况下遇到了很多问题。

  1. 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/*创建符号链接。

  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. 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.

相关问题 使用 monorepo (Lerna + Yarn Workspaces) 共享代码的 ReactJS linting (eslint) 和 transpiling (babel) 错误 - ReactJS linting (eslint) and transpiling (babel) error on shared code using monorepo (Lerna + Yarn Workspaces) "纱线安装命令时出现 ESOCKETTIMEDOUT 错误" - ESOCKETTIMEDOUT error while yarn install command 使用 Yarn 工作区无法完成的 Lerna 可以做什么 - What can be done with Lerna that can not be done using Yarn workspaces 运行“yarn kbn bootstrap”时出错(kibana install) - Error when I run "yarn kbn bootstrap"(kibana install) 纱线安装错误:NX 无法读取未定义的属性(读取“endsWith”) - Yarn install error: NX Cannot read properties of undefined (reading 'endsWith') Yarn install 在安装 node-forge 模块时出错 - Yarn install gives error on installing node-forge module 错误:在使用 yarn encore dev 时安装刺激以使用 enableStimulusBridge() - Error: Install stimulus to use enableStimulusBridge() while using yarn encore dev 使用yarn在带有Docker的Reactjs中“安装\\ r”错误是什么意思? - What does "install\r" error mean in Reactjs with Docker using yarn? 使纱线安装失败 - make failed on yarn install Yarn Workspaces,工作区不发出错误或警告 - Yarn Workspaces, workspace does not emit errors or warnings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM