javascript - 不使用工作区的纱线 nohoist
问题描述
我的一个项目突然无法在 Windows 笔记本电脑上编译,而完全相同的代码在 Mac 上运行。我已经阅读了关于提升和添加 nohoist 的信息,这似乎解决了 Apollo 客户端的问题。
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/tslib",
"**/tslib/**"
]
}
现在,我不使用工作区,但由于我在 package.json 中使用上面的代码,Yarn-W
在添加或删除包时询问参数:
error Running this command will add the dependency to the workspace root rather than
the workspace itself, which might not be what you want - if you really meant it, make it
explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
在我看来,这似乎不是最好的方法。我应该怎么办?
解决方案
通过在您的中添加工作区配置,您package.json
已启用工作区的使用。这就是您收到有关将依赖项添加到工作区根目录的警告的原因。nohoist
是一个工作区唯一的选项;创建它是为了使与 yarn 工作区提升方案不兼容的 3rd 方库仍可在工作区下使用。见https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
“nohoist” 使工作空间能够使用尚未与其提升方案兼容的第 3 方库。这个想法是禁止选定的模块被提升到项目根目录。它们被放置在实际(子)项目中,就像在独立的非工作区项目中一样。
如果您不想使用工作区,则需要从您的工作区中删除工作区配置package.json
并以另一种方式修复您的编译问题。
推荐阅读
- oracle - 无法在 sql loader 中修剪时间戳格式
- python - 使用 Pytest 和 conftest.py 文件时未显示断言错误的预期结果
- python - Twisted 中的合作 - 产生执行上下文
- php - 在 Laravel Eloquent 中获取 HasOne 关系中的特定列
- c# - C# for 循环从不从线程或异步方法执行
- jquery - HTML 表格未完全清除
- reactjs - 在 Gatsby 中允许可选的 GraphQL 数据
- linux-kernel - 如何使用代码中的查找表将热传感器与冷却设备绑定
- python - 在不丢失顺序的情况下摆脱多余的 2D 点
- sql-server - 将 ORDER BY 列作为 SQL 中的参数传递