Asp.net
發布 ASP.NET 核心應用程序:命令“npm install”退出,程式碼為 9009
我有一個帶有 React 前端的 ASP.NET Core 解決方案。我現在遇到一個問題,我無法使用 Visual Studio 中的正常發布視窗發布程式碼。我發佈到 Azure Web 應用程序中的一個 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>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如果我註釋掉前三行(
npm install和兩個 webpack),我可以發布解決方案,但顯然不使用 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.<--- ===================
所以這很尷尬,但對未來的Google員工可能有用。
根本問題很簡單:這是一台沒有
Node.js(或NPM)安裝的新電腦。這使得錯誤消息非常有用:node未找到!解決方案很簡單:安裝
Node.js,確保它在您的 PATH 中並重新啟動電腦。然後你會解決這個問題。
