gpt4 book ai didi

asp.net-core - 在 IIS 上使用 Asp.Net Core 2.1.1 发布 Angular 6 应用程序

转载 作者:行者123 更新时间:2023-12-02 00:31:40 24 4
gpt4 key购买 nike

使用 Visual Studio 2017 (15.7.5) 应用程序正常运行。但是,发布到 IIS 7.5 时,当我尝试访问浏览器时出现以下错误:

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: npm ERR! path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

npm ERR! enoent This is related to npm not being able to find a file.

npm ERR! enoent

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2018-08-01T14_50_15_092Z-debug.log

))

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

InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: npm ERR! path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

npm ERR! enoent This is related to npm not being able to find a file.

npm ERR! enoent

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2018-08-01T14_50_15_092Z-debug.log

Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(string sourcePath, string npmScriptName, ILogger logger)

Stack Query Cookies Headers

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: npm ERR! path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2018-08-01T14_50_15_092Z-debug.log

))

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

Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.WithTimeout(Task task, TimeSpan timeoutDelay, string message)

Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)

Microsoft.AspNetCore.Builder.SpaProxyingExtensions+<>c__DisplayClass2_0+<b__0>d.MoveNext()

Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)

Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Show raw exception details

InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: npm ERR! path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2018-08-01T14_50_15_092Z-debug.log

Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(string sourcePath, string npmScriptName, ILogger logger)

Show raw exception details

System.InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: npm ERR! path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

npm ERR! enoent This is related to npm not being able to find a file.

npm ERR! enoent

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2018-08-01T14_50_15_092Z-debug.log

---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.

at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath, String npmScriptName, ILogger logger)

--- End of inner exception stack trace ---

at Microsoft.AspNetCore.SpaServices.AngularCli.AngularCliMiddleware.StartAngularCliServerAsync(String sourcePath, String npmScriptName, ILogger logger)

生成的日志如下:

info it worked if it ends with ok

verbose cli [ 'D:\Programas\nodejs\node.exe',

verbose cli 'D:\Programas\nodejs\node_modules\npm\bin\npm-cli.js',

verbose cli 'run',

verbose cli 'start',

verbose cli '--',

verbose cli '--port',

verbose cli '52476' ]

info using npm@5.6.0

info using node@v8.11.3

verbose stack Error: ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

verbose cwd C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp

verbose Windows_NT 6.1.7601

verbose argv "D:\Programas\nodejs\node.exe" "D:\Programas\nodejs\node_modules\npm\bin\npm-cli.js" "run" "start" "--" "--port" "52476"

verbose node v8.11.3

verbose npm v5.6.0

error path C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json

error code ENOENT

error errno -4058

error syscall open

error enoent ENOENT: no such file or directory, open 'C:\Sites\NewPro\Microsum.NewPro.ERP\ERPApp\package.json'

error enoent This is related to npm not being able to find a file.

verbose exit [ -4058, true ]

非常欢迎任何建议。

最佳答案

回复晚了,但如果有人在使用更高版本的 .NET Core/Angular SPA 时仍然遇到类似问题;

我已经使用 .NET Core 3.1 生成了空白模板,它是 Angular SPA 模板,它始终可以在开发模式下成功运行,但在发布时会失败并出现与上述相同的错误。这对我来说总是很奇怪,因为如果您已经发布了应用程序,它甚至不应该 寻找 package.json - 它应该加载静态文件。

问题出在它构建的开发环境上——默认情况下,我的 ASPNETCORE_ENVIRONMENT 变量设置为 Development,这意味着 Startup.cs 逻辑将所有 if(env.IsDevelopment()) 检查读取为真,即使在发布。最简单的解决方法是在 VS 项目的“属性”>“发布配置文件”下创建一个新的发布配置文件。将其命名为 Production.pubxml 或其他名称并向其中添加以下元素:<EnvironmentName>Production</EnvironmentName> .然后,当您从“构建”>“发布”菜单发布时,从下拉列表中选择"file"。这会将特定于此应用程序的环境变量添加到 web.config 文件中,从而允许 SpaServices 中间件实际完成其工作,而不是尝试启动节点服务器。

或者,您可以只添加

<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>

已发布的 web.config 文件,在 <aspNetCore 中默认情况下自关闭的元素。这里的缺点是您每次发布应用程序时都需要重新添加它,直到您创建发布配置文件。

关于asp.net-core - 在 IIS 上使用 Asp.Net Core 2.1.1 发布 Angular 6 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51635826/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com