gpt4 book ai didi

yarnpkg - 我如何在 Yarn 2 中共享工作区中的公共(public)依赖项?

转载 作者:行者123 更新时间:2023-12-03 16:32:47 24 4
gpt4 key购买 nike

this 的问题基本相同,但对于 yarn 2。我将共享依赖项放在层次结构的顶部。我相信我目前没有使用 PnP。.yarnrc.yaml

nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-2.2.2.cjs
在最顶层我有 typescript在我想调用的“工作区”之一中安装(但我认为这可能是任何带有二进制文件的模块) tsc ,但它是 command not found: tsc我还注意到一些警告,例如。 graph@workspace:app-lib/graph/packages/app doesn't provide jest@>=24 <25 requested by ts-jest@npm:24.3.0这是在应用程序的父级中提供的。

最佳答案

https://yarnpkg.com/advanced/qa#how-to-share-scripts-between-workspaces

Little-known Yarn feature: any script with a colon in its name (build:foo) can be called from any workspace. Another little-known feature: $INIT_CWD will always point to the directory running the script. Put together, you can write scripts that can be reused this way:


{
"dependencies": {
"typescript": "^3.8.0"
},
"scripts": {
"g:tsc": "cd $INIT_CWD && tsc"
}
}

Then, from any workspace that contains its own tsconfig.json, you'll be able to call TypeScript:


{
"scripts": {
"build": "yarn g:tsc"
}
}

关于yarnpkg - 我如何在 Yarn 2 中共享工作区中的公共(public)依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63731343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com