"bower install" exited with code 9009. in ASP.NET core application

11,481

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

  1. Make sure to install Node.js.
  2. Install bower globally by executing the following command in cmd:

    npm install -g bower

  3. 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.

Share:
11,481

Related videos on Youtube

Rishabh
Author by

Rishabh

Updated on September 16, 2022

Comments

  • Rishabh
    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
    SKull over 6 years
    It's worth mentioning that one needs Node.js installed to do that.
  • lantrix
    lantrix over 6 years
    But what if you need bower to install client side dependencies in your asp.net code; as part of dotnet publish?
  • Jay
    Jay over 6 years
    in 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
    Ala' Alnajjar over 6 years
    It would be best if the line <Exec Command="bower install" /> is the only one commented and leave the rest
  • Mahdi
    Mahdi over 6 years
    yes worked, just close and open vs 2017 and now it is ok
  • Seun S. Lawal
    Seun S. Lawal about 5 years
    There 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
    ashilon over 4 years
    Node.js is installed and it still gives me this error.