![](/img/trans.png)
[英]ReactJS linting (eslint) and transpiling (babel) error on shared code using monorepo (Lerna + Yarn Workspaces)
[英]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 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 在沒有有用文檔的情況下遇到了很多問題。
您需要運行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. 這可能就是您看到“在 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.