简体   繁体   English

错误输出是:未知选项:'--extract-css'

[英]The error output was: Unknown option: '--extract-css'

I get the error "The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Unknown option: '--extract-css'"我收到错误“NPM 脚本‘start’退出,但未指示 Angular CLI 正在侦听请求。错误输出为:未知选项:‘--extract-css’”

I have a project that I have not worked in a while.我有一个我有一段时间没有工作的项目。 It is based on a visual studio angular template.它基于视觉工作室角度模板。 When starting the project I get the error:启动项目时出现错误:

An unhandled exception occurred while processing the request.处理请求时发生未处理的异常。 AggregateException: One or more errors occurred. 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: '--extract-css' (发生了一个或多个错误。(NPM 脚本“start”退出时并未表明 Angular CLI 正在侦听请求。错误输出为:Unknown option: '--extract-css'

npm ERR! npm 错误! code ELIFECYCLE代码生命周期

npm ERR! npm 错误! errno 1错误号 1

npm ERR! npm 错误! angular@0.0.0 start: ng serve --extract-css "--port" "54197" npm ERR! angular@0.0.0 开始: ng serve --extract-css "--port" "54197" --extract ng serve --extract-css "--port" "54197" npm ERR! Exit status 1 npm ERR!退出状态 1 npm ERR! npm ERR! npm 错误! Failed at the angular@0.0.0 start script. angular@0.0.0 启动脚本失败。 npm ERR! npm 错误! This is probably not a problem with npm.这可能不是 npm 的问题。 There is likely additional logging output above.上面可能有额外的日志输出。

npm ERR! npm 错误! A complete log of this run can be found in:可以在以下位置找到此运行的完整日志:

)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) )) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification)

InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. InvalidOperationException:NPM 脚本“开始”退出,但未指示 Angular CLI 正在侦听请求。 The error output was: Unknown option: '--extract-css'错误输出是:未知选项:'--extract-css'

npm ERR! npm 错误! code ELIFECYCLE代码生命周期

npm ERR! npm 错误! errno 1错误号 1

npm ERR! npm 错误! angular@0.0.0 start: ng serve --extract-css "--port" "54197" npm ERR! angular@0.0.0 开始: ng serve --extract-css "--port" "54197" --extract ng serve --extract-css "--port" "54197" npm ERR! Exit status 1 npm ERR!退出状态 1 npm ERR! npm ERR! npm 错误! Failed at the angular@0.0.0 start script. angular@0.0.0 启动脚本失败。 npm ERR! npm 错误! This is probably not a problem with npm.这可能不是 npm 的问题。 There is likely additional logging output above.上面可能有额外的日志输出。

npm ERR! npm 错误! A complete log of this run can be found in:可以在以下位置找到此运行的完整日志:

Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware+d__3.MoveNext() Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware+d__3.MoveNext()

I would like to be able to run the angular template project from visual studio.我希望能够从 Visual Studio 运行角度模板项目。 It runs fine when running through angular cli.通过 angular cli 运行时它运行良好。

I found that by changing the package.json from:我发现通过从以下位置更改 package.json:

"scripts": { "ng": "ng", "start": "ng serve --extract-css", "build": "ng build --extract-css", "scripts": { "ng": "ng", "start": "ng serve --extract-css", "build": "ng build --extract-css",

to:到:

"scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build",

allows to run successfully the angular project template from within visual studio.允许从 Visual Studio 中成功运行 angular 项目模板。 Basically just removing the "--extract-css"基本上只是删除“--extract-css”

To add arguments in script, add them after a -- .要在脚本中添加参数,请将它们添加到--

In the case above, instead of:在上述情况下,而不是:

"scripts": { "ng": "ng", "start": "ng serve --extract-css", "build": "ng build --extract-css",

You can write it as:你可以把它写成:

"scripts": { "ng": "ng", "start": "ng serve", "build": "ng build -- --extract-css",

PS: --extract-css does not work with serve, please refer to angular issue #10532 PS: --extract-css不支持 serve,请参考angular issue #10532

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM