mac*_*ack 40 .net-core angular angular6
我正在尝试启动.NET Core 2/Angular 6 SPA.我使用"dotnet new angular"创建了一个Angular 5应用程序,然后使用angular.io中的本指南进行升级.完成升级后,我尝试使用"dotnet run"运行应用程序,然后出现一个带有错误的丑陋错误页面:
处理请求时发生未处理的异常.
AggregateException:发生一个或多个错误.(发生了一个或多个错误.(NPM脚本'start'退出,但未指示Angular CLI正在侦听请求.错误输出为:Unknown选项:'--extractCss'
InvalidOperationException:NPM脚本'start'退出,但未指示Angular CLI正在侦听请求.错误输出为:未知选项:'--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
Run Code Online (Sandbox Code Playgroud)
我在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()<---
<---
Run Code Online (Sandbox Code Playgroud)
小智 37
对我而言,以下问题解决了这个问题:https://github.com/angular/angular-cli/issues/10666
此外,您还需要编辑package.json文件并从start和build属性中删除--extractCss参数.从:
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
Run Code Online (Sandbox Code Playgroud)
至:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
Run Code Online (Sandbox Code Playgroud)
Isu*_*ana 14
就我而言,我已从azure Web 应用程序中删除了以下应用程序设置,并且站点已开始工作。
键:ASPNETCORE_ENVIRONMENT 值:开发
花了几天时间找出问题:)
小智 11
这个问题也困扰了我几天.现在终于找到了解决方法.显然,Visual Studio会尝试自动为我们启动Angular CLI服务器以及ASP.Net核心进程.对于这个例子,它失败了.
因此,根据微软的文档在这里,我们可以手动启动角CLI服务器.
导航到"ClientApp"文件夹,然后发出:
服务
从控制台启动服务器.
在'Startup.cs'文件中,替换
spa.UseAngularCliServer(..)
同
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
Run Code Online (Sandbox Code Playgroud)
这样您就可以继续调试应用程序.
| 归档时间: |
|
| 查看次数: |
50752 次 |
| 最近记录: |