"bower install" exited with code 9009. in ASP.NET core application
Solution 1
Also worked for me by removing the code below in the project file.
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
However it did cause a couple of typescript issues with duplicate method names, add the below code to the tsconfig.json file
"exclude": [
"obj"
]
Solution 2
- Make sure to install Node.js.
-
Install bower globally by executing the following command in cmd:
npm install -g bower
Close Visual Studio, then open it and try again.
Solution 3
What worked for me.
I went to project file (in VS-2017 Explorer you can right-click it and edit it)
Then I deleted (or commented) the Target node
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="bower install" />
<Exec Command="dotnet bundle" />
</Target>
Everything was fine without installing anything else.
Solution 4
It'is a bug of Visual Studio. Visual Studio should use the NodeJS that defined in the options (Project and Solutions/Web Package Management/External Web Tools). I don`t know why but it does not use internal tools (path: $VSINSTALLDIR/web/External) for the prepublish scripts in csproj file.
1) You need install NodeJS and Npm globaly. Also check that in External Web Tools "$PATH" option checked. If you use bower or any other node tool in your prepublish scipts you have to install it globaly.
npm install -g bower
npm install -g gulp
2)Another way. you can delete appropriated "Exec" sections from csproj file and just do prepublish actions manualy. Usualy that's needed not so often.
Solution 5
Locate the web external folder under Visual Studio installation, e.g. C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Web\External
You should see a file called bower.cmd. If it's not there then you're on your own.
Add this directory to the Path system Environment Variable.
Restart Visual Studio if you have it open so that it picks up the change.
Related videos on Youtube
Rishabh
Updated on September 16, 2022Comments
-
Rishabh over 1 year
I am facing an issue of
The command "bower install" exited with code 9009
while publishing the ASP.NET core-MVC application with entity framework. I am using VS-2017.
I got many suggestions in your portal of downloading
node.js
globally, but as I am very new to this system I don't know how to do so. Or if there is any other solution for that please let me know. -
SKull over 6 yearsIt's worth mentioning that one needs Node.js installed to do that.
-
lantrix over 6 yearsBut what if you need bower to install client side dependencies in your asp.net code; as part of
dotnet publish
? -
Jay over 6 yearsin my case along with the above change, I will have to restart the solution to apply csproj file changes ( though I have edited the file within VS IDE)
-
Ala' Alnajjar over 6 yearsIt would be best if the line
<Exec Command="bower install" />
is the only one commented and leave the rest -
Mahdi over 6 yearsyes worked, just close and open vs 2017 and now it is ok
-
Seun S. Lawal about 5 yearsThere is no need to delete the tags. Asp.net need to perform those operations, so what you need to do is ; - download and install Nodejs. - Restart visual studio . You will be just fine
-
ashilon over 4 yearsNode.js is installed and it still gives me this error.