简体   繁体   English

依赖问题(ASP.NET Core + React.js)

[英]Dependency problem (ASP.NET Core + React.js)

after creating a new ASP .NET Core (3.1) App with React.js project I'm trying to run it, but I'm getting a following error:在使用 React.js 项目创建新的 ASP .NET Core (3.1) 应用程序后,我尝试运行它,但出现以下错误:

An unhandled exception occurred while processing the request.
AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the create-react-app server was listening for requests. The error output was:

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"webpack": "4.42.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

C:\Users\xxxx\node_modules\webpack (version: 5.25.1)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.

6. Check if C:\Users\xxx\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.

7. Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE

npm ERR! errno 1

))
System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)

InvalidOperationException: The NPM script 'start' exited without indicating that the create-react-app server was listening for requests. The error output was:

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"webpack": "4.42.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

C:\Users\xxx\node_modules\webpack (version: 5.25.1)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.

6. Check if C:\Users\xxx\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.

7. Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

I've tried following instructions included in this error, but then I'm running into a blank page with a 400 error.我已尝试按照此错误中包含的说明进行操作,但随后我遇到了一个带有 400 错误的空白页面。 Does anyone knows how to fix it?有谁知道如何解决它? I've tried everything I have found on the internet (also installing older version of webpack manually), but so far nothing seems to work.我已经尝试了我在互联网上找到的所有内容(还手动安装了旧版本的 webpack),但到目前为止似乎没有任何效果。

To fix the problem you need the node package manager (npm) in addition to the dotnet 3.1 SDK.要解决此问题,除了 dotnet 3.1 SDK 之外,您还需要节点 package 管理器 (npm)。

You can download and install it here: https://nodejs.org/de/ (Whereby I would recommend chocolatey for Windows)您可以在此处下载并安装它: https://nodejs.org/de/ (我会推荐用于 Windows 的巧克力)

After the installation you can check your npm version with npm --version .安装后,您可以使用npm --version检查您的 npm 版本。 If there is no answer and you are on Windows, you have to restart your computer once.如果没有答案并且您在 Windows 上,则必须重新启动计算机一次。

If npm is successfully installed, you have to navigate with the terminal (or powershell) to your project folder and run the command npm install to reinstall all dependencies.如果 npm 安装成功,您必须使用终端(或 powershell)导航到您的项目文件夹并运行命令npm install以重新安装所有依赖项。

If you still have problems installing all modules, you can check the package.json file to see which packages you have installed with which version and then simply update or delete packages there.如果您在安装所有模块时仍然遇到问题,您可以检查 package.json 文件以查看您使用哪个版本安装了哪些软件包,然后简单地更新或删除那里的软件包。 After you have finished editing your package.json you have to run npm install again.完成编辑 package.json 后,您必须再次运行npm install

This is a general help on how you can get closer to your issue这是有关如何更接近您的问题的一般帮助

I ran into this problem a while ago.我不久前遇到了这个问题。 Go to C:\Users\User there is a folder named node_modules delete it. Go 到C:\Users\User有一个名为node_modules的文件夹删除它。 don't run npm install... just go on VS (close and restart if its open) and create a new React.Net core project.不要在 VS 上运行npm install...只需 go (如果打开,请关闭并重新启动)并创建一个新的 React.Net 核心项目。 VS terminal will download and install all the packages. VS 终端将下载并安装所有软件包。 This solved my problem.这解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET 核心中的循环依赖问题 - Problem with Circular dependency in ASP.NET Core 尝试使用 React.js 和 Redux 将 Azure B2c 身份验证添加到 Asp.net 核心 - trying to add Azure B2c authentication to Asp.net core with React.js and Redux ASP.NET Core with React.JS 如何为后端打开单独的浏览器? - ASP.NET Core with React.JS How to open separate Browser for the Backend? 无法从 React.js (CORS) 访问 ASP.NET Core API - ASP.NET Core API not accessible from React.js (CORS) 全栈应用中基于角色的 Active Directory 身份验证和授权(React.js + ASP.Net Core) - Role-based Active Directory authentication and authorization in full stack app (React.js + ASP.Net Core) 将“react js”构建到我的“asp.net core web api”的 wwwroot 文件夹时出现路由问题 - Routing problem when building "react js" to wwwroot folder of my "asp.net core web api" IAuthorizationFilter ASP.Net Core 3 中的依赖注入 - Dependency Injection in IAuthorizationFilter ASP.Net Core 3 ASP.Net Core中的依赖注入 - Dependency injection within ASP.Net Core ASP.NET Core 依赖注入问题 - ASP.NET Core Dependency Injection Issues ASP.NET Core中的循环依赖 - Circular dependency in ASP.NET Core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM