I am using Visual Studio 2022. I created a new React project using React and ASP.NET Core template:
我正在使用Visual Studio 2022。我使用Reaction和ASP.NET核心模板创建了一个新的Reaction项目:
The code runs fine:
代码运行良好:
But I see the following error:
但我看到以下错误:
Error: TS2304 (TS) Cannot find name 'ExtendableEvent'.
The error is shown on this file:
错误显示在此文件上:
When I check the path, I can see that I have the following versions of TypeScript installed:
当我检查路径时,可以看到我安装了以下版本的TypeScrip:
And this is what I have in packages.json
:
这是我在Packages.json中拥有的内容:
How can I resolve this issue?
我如何解决此问题?
Update
I believe the issue here is that the error is raised on file under TypeScript/4.3 but in my package.json
the requirement for TypeScript is min: 4.9.5. However I am not sure how to change the TypeScript version?
我认为这里的问题是,这个错误是在文件的tyescript/4.3下提出的,但在我的Package.json中,对tyescript的要求是min:4.9.5。但是,我不确定如何更改打字版本?
My node.js version is 18.17
我的node.js版本是18.17
更多回答
do you have webworker
in lib
setting?
你在lib设置中有网络工作者吗?
upgrading the nodejs to the latest version could solve the issue in my test, could you pls take a try?
把NodeJS升级到最新版本可以解决我测试中的问题,你能试一试吗?
@Lesiak: I am sorry, I don't follow your question... I am very new to using react
@Lesiak:对不起,我没有听懂你的问题……我对使用REACTION非常陌生
@HoomanBahreini Can you post your tsconfig.json please?
@HOOMANBHREINI你能发一下你的tsconfig.json吗?
@Lesiak: Thanks but I managed to resolved the issue by installing TypeScript SDK
. Have added an answer.
@Lesiak:谢谢,但我通过安装TypeScrip SDK解决了这个问题。已经添加了一个答案。
优秀答案推荐
I have a test in my side before and I also faced the error as yours, and I noticed that I didn't use the latest version of nodejs so that I try to update the nodejs by uninstall the old SDK and install the new version, then the issue disappeared. But I didn't remember the old version of my SDK, nor have a screenshot for the same error I met... So I try to reproduce but no luck to reproduce again.
我之前做过一次测试,我也和你一样面对这个错误,我注意到我没有使用最新版本的NodeJS,所以我试图通过卸载旧SDK并安装新版本来更新NodeJS,然后问题就消失了。但我不记得我的SDK的旧版本了,也没有我遇到的相同错误的屏幕截图……所以我试着繁殖,但没有再次繁殖的运气。
What I can say is, when I start to test with v15.9.0
, I can create the project through the template successfully, before that, I kept getting exception when creating the project. And I'm sure with v18.16.1
everything worked.
我可以说的是,当我开始测试v15.9.0时,我可以通过模板成功地创建项目,在此之前,我在创建项目时不断出现异常。我相信在v18.16.1中,一切都能正常工作。
I managed to resolve the issue by updating Visual Studio 2022 and also Installing TypeScript SDK.
我设法解决了这个问题,方法是更新了Visual Studio 2022并安装了TypeScrip SDK。
To Install TypeScript SDK:
要安装TypeScript SDK,请执行以下操作:
Run Visual Studio 2022 Installer, and click on Modify under Build Tools:
Choose Individual Components and Make Sure TypeScript SDK is installed.
This answer helped me to resolve the issue.
这个回答帮助我解决了这个问题。
更多回答
thanks for your answer... I don't think this is my issue because my node version is already 18.17... I have added a screenshot to the question.
谢谢你的回答..。我不认为这是我的问题,因为我的节点版本已经是18.17了。我已经为这个问题添加了一个屏幕截图。
thanks for your reply and we might keep working on it.
谢谢你的回复,我们可能会继续努力。
Thanks again for your help. I managed to resolve the issue by installing TypeScript SDK (answer below). Not quite sure why the only available option is TypeScript 4.3 SDK (which seems old) but installing it resolved the issue.
再次感谢您的帮助。我设法通过安装TypeScrip SDK解决了这个问题(答案如下)。不太确定为什么唯一可用的选项是TypeScrip 4.3 SDK(它似乎很旧),但安装它解决了问题。
thanks for informing me about it and I voted it : )
谢谢你告诉我这件事,我投票了:)
我是一名优秀的程序员,十分优秀!