node.js - Nestjs 在 monorepo 中获取 @types/react 错误
问题描述
我正在使用 Yarn 工作区使用 monorepo 工作我的后端(使用 Nestjs)和我当前的前端(使用 Tailwind 的 CRA,我将来还会添加一个 React Native 应用程序),我设法解决了我的 React 应用程序的一些问题,并且它现在正常启动,但现在我的 Nestjs 应用程序正在抛出有关@types/react
.
这是我尝试启动后端应用程序时出现的一小部分错误。
../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3244:13 - error TS2717: Subsequent property declarati
ons must have the same type. Property 'view' must be of type 'SVGProps<SVGViewElement>', but here has type 'SVGProps<SVGVi
ewElement>'.
3244 view: React.SVGProps<SVGViewElement>;
~~~~
../node_modules/@types/react/index.d.ts:3245:13
3245 view: React.SVGProps<SVGViewElement>;
~~~~
'view' was also declared here.
../node_modules/@types/react/index.d.ts:3057:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
3057 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent
<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3054:14
3054 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticCompo
nent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
'LibraryManagedAttributes' was also declared here.
Found 177 error(s).
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
这是我的 monorepo 的配置和结构。
.
├── assets
├── mobile-app
├── mobile-pwa <-- Not yet included in the packages.
├── nest-backend
├── node_modules
├── package.json
├── readme.md
└── yarn.lock
5 directories, 3 files
根package.json
{
"name": "foo",
"private": true,
"workspaces": {
"packages": ["nest-backend", "mobile-pwa"]
},
"nohoist": ["**/**"]
}
React 应用程序package.json
(将省略一些内容,因为它非常大)
{
"name": "@foo/mobile-pwa",
"version": "0.0.1",
"private": true,
"license": "UNLICENSED",
}
还有 Nest.js 后端package.json
{
"name": "@beextravel/nest-backend",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
}
解决方案
尝试:
"workspaces": {
"packages": ["nest-backend", "mobile-pwa"],
"nohoist": ["**/**"]
}
推荐阅读
- python-3.x - 如何正确绘制小浮点数
- swift - 单击按钮后如何更改变量 UITextView?
- javascript - 做出反应。如何将 arg 传递给 onClick 调用的函数而不自动触发它
- sql - SQL 语句中的 IN 运算符不起作用?
- request - Cheerio 在 Google Cloud 功能中未按预期工作
- python - 如何使用 BFS 和 DFS 计算两个网格坐标之间的最短路径
- asp.net - asp.NET 核心发布 Trimmed 退出,错误代码为 -532462766
- azure - Azure DevOps YAML 管道:Jenkins 队列作业输出变量
- algorithm - 弗洛伊德算法
- security - 谷歌云的安全基准