none
Cannot publish my .NET Core 1.0 web app - receive the error message "'bower' is not recognized as an internal or external command, operable program or batch file"

    Question

  • I cannot publish my .NET Core 1.0 web app. I receive the error message "'bower' is not recognized as an internal or external command, operable program or batch file" when Visual Studio tries to run "bower install". I recently migrated my web app from Visual Studio Community 2015 to Visual Studio Community 2017.
    Thursday, March 09, 2017 7:20 AM

Answers

  • Actually, what I ended up doing, which is similar to Fletch's suggestion, is install Node.js from nodejs.org on my computer and run the command "npm install -g bower" in the Command Prompt as an administrator. Then, I tried publishing my web app in Visual Studio 2017, and voilà, the command "bower install" ran without any problems.

    I did not want to run "bower init" in my web project folder, as Fletch suggested, because I already had a bower.json file in there. My understanding is that "bower init" creates a bower.json file, so I didn't want to replace what I already had.

    I thought that this would have been the solution after searching for hours on Bing on how to resolve the issue. I just did not want to try it because I thought Visual Studio would go ballistic if I were to install Node.js from an external source instead of installing it in Visual Studio's NuGet Package Manager, which is what I tried, but I believe the publish operation depends on the Command Prompt for running its commands, which requires bower to be added to the PATH, which requires Node.js to be installed from nodejs.org.

    Thanks for your help.

    • Marked as answer by bhlee90 Friday, March 10, 2017 11:00 PM
    Friday, March 10, 2017 10:59 PM

All replies

  • Per a suggestion on this page, I removed the following lines from my .csproj file in my repository.

      </ItemGroup>

      <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
        <Exec Command="bower install" />
        <Exec Command="dotnet bundle" />
      </Target>

      <ItemGroup>

    This allowed me to publish the app, successfully, but I get a 500 Internal Server Error when I go to the Azure web app's URL in my web browser. When I test the app in "Debug" mode, it runs fine. Not sure why the Azure web app fails.


    • Edited by bhlee90 Friday, March 10, 2017 3:23 AM Adding a reference
    Friday, March 10, 2017 3:20 AM
  • Still, I would like to find out why I got the error "'bower' is not recognized as an internal or external command, operable program or batch file", as I mentioned in my first post.
    Friday, March 10, 2017 3:31 AM
  • Hi friend,

    For this error , you could fix it by below steps:

    1. Open the command prompt
    2. Navigate to web project folder
    3. Run bower init

    You could more details from following link:  

    http://stackoverflow.com/questions/26521889/how-to-use-bower-installed-from-nuget-in-visual-studio

    Best regards,

    Fletch



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 10, 2017 4:09 PM
  • Actually, what I ended up doing, which is similar to Fletch's suggestion, is install Node.js from nodejs.org on my computer and run the command "npm install -g bower" in the Command Prompt as an administrator. Then, I tried publishing my web app in Visual Studio 2017, and voilà, the command "bower install" ran without any problems.

    I did not want to run "bower init" in my web project folder, as Fletch suggested, because I already had a bower.json file in there. My understanding is that "bower init" creates a bower.json file, so I didn't want to replace what I already had.

    I thought that this would have been the solution after searching for hours on Bing on how to resolve the issue. I just did not want to try it because I thought Visual Studio would go ballistic if I were to install Node.js from an external source instead of installing it in Visual Studio's NuGet Package Manager, which is what I tried, but I believe the publish operation depends on the Command Prompt for running its commands, which requires bower to be added to the PATH, which requires Node.js to be installed from nodejs.org.

    Thanks for your help.

    • Marked as answer by bhlee90 Friday, March 10, 2017 11:00 PM
    Friday, March 10, 2017 10:59 PM