'how to use npm install's --force flag during Visual Studio publish process?
I have an Angular project in Visual Studio, along with a publish profile to publish to IIS. I've been successfully using this process in this project for some time now, but suddenly today it wants to give me dependency issues during publish. However, there are no such dependency issues when simply running from source (IIS Express).
Here is some of the output during publishing:
MYPROJECT -> C:\Users\ME\Documents\Repositories4\MYPROJECT\bin\Release\net5.0\MYPROJECT.Views.dll
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"8.2.12" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^6.0.0-rc.0 || ^6.0.0" from [email protected]
npm ERR! node_modules/ng-connection-service
npm ERR! ng-connection-service@"^1.0.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^6.0.0-rc.0 || ^6.0.0" from [email protected]
npm ERR! node_modules/ng-connection-service
npm ERR! ng-connection-service@"^1.0.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I have repeatedly tried uninstalling/reinstalling, deleting node_modules folder and reinstalling, etc.
Is it possible to modify Visual Studio's publish commands to include --force during npm install? (If so, where would I do that?) Would that maybe solve the issue? Or do you have any other ideas how to get this to publish? I don't think the actual dependency issue is an issue, seeing as how I am able to run from source just fine, so I feel like if I could just tell Visual Studio to force it anyway, then that would probably work.
Thanks in advance!
Solution 1:[1]
Apparently the publish process has these commands defined in the .csproj file:
<!-- 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' " />
I updated that to use the --force flag during npm install.
It fixed a couple things but still having issues publishing, despite being able to run from source, and despite my coworker being able to check out the same repo and publish it just fine. Something is wonky with my npm packages or maybe typescript, IDK. I'll update this answer if/when I figure it out. Until then, please let me know if any of you have any ideas.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ruttergod |
