我对 Yarn Workspaces 感到困惑。我遵循了本教程:https://medium.com/trabe/monorepo-setup-with-lerna-and-yarn-workspaces-5d747d7c0e91但在其中一个子项目中,我仍然将包添加到 node_modules 中,这些包是从根节点模块。完整的测试仓库在这里:https ://github.com/donker/Dnn.React.Test
根包.json:
{
"name": "dnn-react-test",
"version": "1.0.0",
"description": "DNN React Component Library",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dnnsoftware/Dnn.React.Common.git"
},
"scripts": {
},
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "2.11.0"
}
}
子项目包.json:
{
"name": "dnn-tooltip",
"version": "0.2.5",
"description": "Display an icon and associated tooltip showing a message from an array parameter",
"main": "index.js",
"scripts": {
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dnnsoftware/Dnn.React.Common"
},
"dependencies": {
"lodash": "4.17.10",
"react-portal-tooltip": "2.4.0",
"dnn-global-styles": "^0.0.5"
}
}
结果:packages/Tooltip/node_modules/lodash 创建。
预期:工具提示使用根文件夹中的 node_modules/lodash。