"npm install" exited with code -1 on dotnet publish
See original GitHub issueSteps to reproduce
- Update SPA templates with
dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0
. - Create a new SPA app with
dotnet new angular
. - Run
dotnet restore
in the root. - Run
npm i
in theClientApp
. - Run
dotnet publish -c release -r win-x64
in the root.
Expected behavior
Get a published app.
Actual behavior
Get the error MSB3073: The command "npm install" exited with code -1.
.
Additional info
App successfully run in debug mode in VS code. Only publish doesn’t work.
Environment data
dotnet --info
output:
.NET Command Line Tools (2.1.201)
Product Information:
Version: 2.1.201
Commit SHA-1 hash: 7932dc6179
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.201\
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
dotnet publish -c release -r win-x64 -v diag
output (>38MB):
https://yadi.sk/i/bt6ATlRG3Z8sAc
pt.csproj
source code:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<!-- Set this to true if you enable server-side prerendering -->
<BuildServerSideRenderer>false</BuildServerSideRenderer>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build -- --prod" />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr -- --prod" Condition=" '$(BuildServerSideRenderer)' == 'true' " />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
<DistFiles Include="$(SpaRoot)node_modules\**" Condition="'$(BuildServerSideRenderer)' == 'true'" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
c# - error MSB3073: The command "npm install" exited with ...
This will delete frontend from your container completely if I remember correctly. However if you want to remain it within container just make ......
Read more >Error MSB3073 The command "npm run build" exited with ...
The error I faced on visual studio during the build was the below. "npm run build" exited with code 1 - Visual Studio...
Read more >Solution for “npm install existed with error code -1” while ...
Solution for “npm install existed with error code -1” while publishing .NET Core application to Azure web app.
Read more >How to solve npm ERR! code 1 when running npm install
Fix npm error code 1 by updating your dependencies · Update one package version in package.json file · Then run npm install ·...
Read more >Error: Command "npm run build" exited with 1 - 🙋Get Help
Hello all, I'm having problem redeploying my frontity project to vercel. I used to deploy succefully. Ever since I upgraded node to 18...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, try and edit your project file by removing the section below:
Then save, re-publish again.
I too faced this issue in CI build, the issue was, i was using 10.X version of the node.js in my local development, while default CI build was using the 6.X version of node.js for building the solution. i added new job in the pipeline before my solution build job in the pipeline - “Use Node 10.X” and mentioned the specific version which i required for. i pushed latest into the master branch and solution got build successfully. 😃