Lar*_*ard 6 asp.net asp.net-core-mvc npm-install asp.net-core asp.net-core-2.0
我有一个带有React前端的ASP.NET Core解决方案.我现在有一个问题,我无法使用Visual Studio中的正常发布窗口释放代码.我发布到Azure网络应用程序内的Web应用程序,它可以完美地用于我所有其他以相同方式构建的解决方案.
代码在本地完美运行,我可以在npm install本地运行而不会出现问题.
发布时,错误显然来自某些未找到的文件.在我的项目文件中,我一直在调试,发现这是一个挑战:
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
Run Code Online (Sandbox Code Playgroud)
Visual Studio中的错误:
Severity Code Description Project File Line Suppression State
Error The command "npm install" exited with code 9009. Likvido.CreditRisk C:\Users\MYNAME\Documents\Github\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk.csproj 75
Run Code Online (Sandbox Code Playgroud)
如果我注释掉前三行(npm install和两个webpacks),我可以发布解决方案,但显然没有使用JavaScript.
不知道怎么解决这个问题?至少,如何更好地调试它?
Visual Studio中的可视错误:
GUI中引用的日志文件:
09/04/2018 11.07.03
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---
===================
Run Code Online (Sandbox Code Playgroud)
Lar*_*ard 13
所以这很令人尴尬但对未来的Google员工有用.
根本问题很简单:它是一台未安装Node.js(或NPM)安装的新计算机.这使得错误消息非常有用:node找不到!
解决方案很简单:安装Node.js,确保它在PATH中并重新启动计算机.那你就解决了这个问题.
| 归档时间: |
|
| 查看次数: |
8196 次 |
| 最近记录: |