NPM 脚本 'start' 退出但未指示 Angular CLI 正在侦听请求
The NPM script 'start' exited without indicating that the Angular CLI was listening for requests
我正在尝试启动 .NET Core 2/Angular 6 SPA。我使用“dotnet new angular”创建了一个 Angular 5 应用程序,然后使用 angular.io 中的 this guide 继续升级。完成升级后,我尝试使用“dotnet 运行”运行 应用程序,但我得到一个丑陋的错误页面,其中包含以下错误:
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
Angular CLI was listening for requests. The error output was: Unknown
option: '--extractCss'
InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
我想也许我在升级过程中错过了一个步骤,我又尝试了第二次,但得到了同样的错误。
以下是我在创建应用程序后采取的步骤:
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
ng update @angular/core
npm install --save @angular/material @angular/cdk @angular/animations hammerjs
npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json
我 运行 在 Windows 10 (1703) Enterprise 上使用 Node 版本 9.4.0 和 .Net Core 2.1.200。
关于如何解决这个问题有什么想法吗?这是完整的堆栈跟踪:
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<>c.<Attach>b__2_0(Task`1 task)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.<WithTimeout>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.<PerformProxyRequest>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.SpaProxyingExtensions.<>c__DisplayClass2_0.<<UseProxyToSpaDevelopmentServer>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
) ---> System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<>c.<Attach>b__2_0(Task`1 task)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
---> (Inner Exception #0) System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()<---
<---
对我来说,这个和以下内容解决了这个问题:https://github.com/angular/angular-cli/issues/10666
并且您还需要编辑 package.json 文件并从开始和构建 属性 中删除 --extractCss 参数。
来自:
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
至:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
如果上述解决方案不起作用,您可以尝试以下对我有用的方法。
场景:将工作 VS 2017 解决方案:核心 web api & angular spa 项目转移到新安装的电脑上;给我上面的错误。
解决方案:通过 visual studio 安装程序安装 node.js 工作负载后,node.js for windows (https://nodejs.org/en/download/) 和必要的 windows 功能对于 IIS;我回到了正轨。
主要安装是 visual studio 的 node.js 和 windows(包含 npm),必须同时安装它们才能工作。可能是命令提示符的路径配置....
这个问题也困扰了我几天。现在终于有办法了。显然,Visual Studio 试图与 ASP.Net 核心进程一起为我们自动启动 Angular CLI 服务器。对于这个实例,它失败了。
因此根据 Microsoft Doc here,我们可以手动启动 Angular CLI 服务器。
导航到 'ClientApp' 文件夹,然后发出:
服务
从控制台启动服务器。
在'Startup.cs'文件中,替换
spa.UseAngularCliServer(..)
和
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
- F5 像往常一样启动ASP.Net核心项目。
这样您就可以继续调试应用程序了。
Joe 和 Jays 的解决方案都有效。要在不更改代码的情况下使用默认模板配置,您只需按照 Jay 上面的说明为 windows 安装 node.js,然后重新启动 VS。
https://nodejs.org/en/download/
关于使用 vs 和 vscode 创建、配置和部署核心 Angular 项目的优秀教程。还包括 IIS 设置。
https://www.codeproject.com/Articles/1250961/Deploying-an-Angular-Application-with-ASP-NET-Core
尝试执行以下操作
- 打开一个Powershell
- 导航到 clientapp 目录
- 运行
npm audit fix
这也适用于 ReactJS 和 VueJS 项目。
就我而言,我已经删除了 Azure Web 应用程序中的应用程序设置,网站开始运行。
键:ASPNETCORE_ENVIRONMENT
价值:发展
花了几天时间才弄清楚问题:)
我试图让一个 GitHub 项目从头开始工作。这些是我为此所做的事情:
- 下载并安装 NodeJS:https://nodejs.org/en/download
- 从 GitHub
下载任何 AngularJS 项目
- 运行 命令提示符并导航到 "client-app" 文件夹:
dotnet new angular -o "C:\Users\me\OneDrive\Documents\Visual Studio 2017\Projects\myproject\myproject-dev\myproject-client-app" --force
- 输入指令:
npm install -g @angular/cli
- 输入命令:
npm build fix
- 输入指令:
npm run ng
- 输入指令:
npm start
- 输入命令:
ng start --extract-css
(我实际上不需要输入最后一个命令,因为 npm start
为我的项目启动了这个命令,但情况可能并非总是如此...)
在'Startup.cs'文件中,替换
spa.UseAngularCliServer(..)
和
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
然后 F5 启动 ASP .NET Core 项目,就像我们开始调试应用程序一样。
完成所有这些之后,该项目应该 运行。
VS 2019 - 通过导航到 ClientApp 文件夹和 运行 npm install
解决了错误。确保您的系统上安装了 npm
以及 Angular Cli。如果在安装 Angular Cli 时遇到问题,您可以在 package.json 文件中将脚本从 ng serve
更改为 npm run start
。
如果您使用 nvm 安装了多个 Node 版本。
可以在终端cd到项目根目录执行
nvm use x.x.x
这解决了我的问题
帮帮我。
- 从安装程序 vs;
安装节点 environment.js
2)从官方网站为您的 OS 安装 node.js;
- 通过 PowerShell 安装 npm。从管理员打开,转到 Client App 文件夹和 运行 npm install。然后 运行 npm audit fix(修复错误)。
我遇到了同样的问题并通过从项目中卸载 Nodejs 并从 Nodejs.org
安装最新版本的 Nodejs 来解决它
我正在尝试启动 .NET Core 2/Angular 6 SPA。我使用“dotnet new angular”创建了一个 Angular 5 应用程序,然后使用 angular.io 中的 this guide 继续升级。完成升级后,我尝试使用“dotnet 运行”运行 应用程序,但我得到一个丑陋的错误页面,其中包含以下错误:
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 Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
我想也许我在升级过程中错过了一个步骤,我又尝试了第二次,但得到了同样的错误。
以下是我在创建应用程序后采取的步骤:
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
ng update @angular/core
npm install --save @angular/material @angular/cdk @angular/animations hammerjs
npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json
我 运行 在 Windows 10 (1703) Enterprise 上使用 Node 版本 9.4.0 和 .Net Core 2.1.200。
关于如何解决这个问题有什么想法吗?这是完整的堆栈跟踪:
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<>c.<Attach>b__2_0(Task`1 task)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.<WithTimeout>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.<PerformProxyRequest>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.SpaProxyingExtensions.<>c__DisplayClass2_0.<<UseProxyToSpaDevelopmentServer>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
) ---> System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<>c.<Attach>b__2_0(Task`1 task)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
---> (Inner Exception #0) System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extractCss'
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.<StartAngularCliServerAsync>d__3.MoveNext()<---
<---
对我来说,这个和以下内容解决了这个问题:https://github.com/angular/angular-cli/issues/10666
并且您还需要编辑 package.json 文件并从开始和构建 属性 中删除 --extractCss 参数。 来自:
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
至:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
如果上述解决方案不起作用,您可以尝试以下对我有用的方法。
场景:将工作 VS 2017 解决方案:核心 web api & angular spa 项目转移到新安装的电脑上;给我上面的错误。
解决方案:通过 visual studio 安装程序安装 node.js 工作负载后,node.js for windows (https://nodejs.org/en/download/) 和必要的 windows 功能对于 IIS;我回到了正轨。
主要安装是 visual studio 的 node.js 和 windows(包含 npm),必须同时安装它们才能工作。可能是命令提示符的路径配置....
这个问题也困扰了我几天。现在终于有办法了。显然,Visual Studio 试图与 ASP.Net 核心进程一起为我们自动启动 Angular CLI 服务器。对于这个实例,它失败了。
因此根据 Microsoft Doc here,我们可以手动启动 Angular CLI 服务器。
导航到 'ClientApp' 文件夹,然后发出:
服务
从控制台启动服务器。
在'Startup.cs'文件中,替换
spa.UseAngularCliServer(..)
和
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
- F5 像往常一样启动ASP.Net核心项目。
这样您就可以继续调试应用程序了。
Joe 和 Jays 的解决方案都有效。要在不更改代码的情况下使用默认模板配置,您只需按照 Jay 上面的说明为 windows 安装 node.js,然后重新启动 VS。 https://nodejs.org/en/download/
关于使用 vs 和 vscode 创建、配置和部署核心 Angular 项目的优秀教程。还包括 IIS 设置。 https://www.codeproject.com/Articles/1250961/Deploying-an-Angular-Application-with-ASP-NET-Core
尝试执行以下操作
- 打开一个Powershell
- 导航到 clientapp 目录
- 运行
npm audit fix
这也适用于 ReactJS 和 VueJS 项目。
就我而言,我已经删除了 Azure Web 应用程序中的应用程序设置,网站开始运行。
键:ASPNETCORE_ENVIRONMENT 价值:发展
花了几天时间才弄清楚问题:)
我试图让一个 GitHub 项目从头开始工作。这些是我为此所做的事情:
- 下载并安装 NodeJS:https://nodejs.org/en/download
- 从 GitHub 下载任何 AngularJS 项目
- 运行 命令提示符并导航到 "client-app" 文件夹:
dotnet new angular -o "C:\Users\me\OneDrive\Documents\Visual Studio 2017\Projects\myproject\myproject-dev\myproject-client-app" --force
- 输入指令:
npm install -g @angular/cli
- 输入命令:
npm build fix
- 输入指令:
npm run ng
- 输入指令:
npm start
- 输入命令:
ng start --extract-css
(我实际上不需要输入最后一个命令,因为 npm start
为我的项目启动了这个命令,但情况可能并非总是如此...)
在'Startup.cs'文件中,替换
spa.UseAngularCliServer(..)
和
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
然后 F5 启动 ASP .NET Core 项目,就像我们开始调试应用程序一样。
完成所有这些之后,该项目应该 运行。
VS 2019 - 通过导航到 ClientApp 文件夹和 运行 npm install
解决了错误。确保您的系统上安装了 npm
以及 Angular Cli。如果在安装 Angular Cli 时遇到问题,您可以在 package.json 文件中将脚本从 ng serve
更改为 npm run start
。
如果您使用 nvm 安装了多个 Node 版本。
可以在终端cd到项目根目录执行
nvm use x.x.x
这解决了我的问题
帮帮我。
- 从安装程序 vs; 安装节点 environment.js
2)从官方网站为您的 OS 安装 node.js;
- 通过 PowerShell 安装 npm。从管理员打开,转到 Client App 文件夹和 运行 npm install。然后 运行 npm audit fix(修复错误)。
我遇到了同样的问题并通过从项目中卸载 Nodejs 并从 Nodejs.org
安装最新版本的 Nodejs 来解决它