How to get bower/npm working

jhoppe's Avatar

jhoppe

20 Jul, 2016 04:22 PM

Can you provide more details on how to get bower/npm working with AppHarbor? It looks like I was able to get the packages to download to AppHarbor, but then the files all result in 404. As per another post on the support site, I added a postbuild event that I thought would get it working, but it doesn't. I read that the AppHarbor input and output folders are different, so I'm guessing that my node_modules folder needs to be copied from the input directory to the output directory? But the below doesn't work.

The build log seems to indicate that the copy command runs before the NPM packages are installed.

My csproj contains:
  <PropertyGroup>
    <PostBuildEvent>if not exist "$(WebProjectOutputDir)\node_modules" md "$(WebProjectOutputDir)\node_modules"
start /MIN xcopy /s /y /R "$(MSBuildProjectDirectory)\node_modules\*.*" "$(WebProjectOutputDir)\node_modules"</PostBuildEvent>
  </PropertyGroup>
  <Target Name="AfterBuild">
    <Exec Command="npm install" />
    <Message Text="Npm install finished" />
  </Target>

I changed the PostBuildEvent to include "npm install", but then it seems like couldn't find the packages.json file because it wasn't copied to the output directory.

Please see build fb1b6ab3 on my HoppeUAT site.

  1. Support Staff 1 Posted by rune on 21 Jul, 2016 01:13 AM

    rune's Avatar

    Hi,

    Take a look at my comment in this discussion -- the customer was able to get bower up and running with the steps outlined there. Seems like that would also apply to the issue you're facing?

    Best,
    Rune

  2. 2 Posted by jhoppe on 21 Jul, 2016 11:53 AM

    jhoppe's Avatar

    Yes this is the thread I was referring to. Do you have any more info on
    this? I wasn't able to get it working.

  3. Support Staff 3 Posted by rune on 24 Jul, 2016 09:24 PM

    rune's Avatar

    Hi,

    That depends -- what wasn't working and/or what errors did you encounter? :-)

    One possible cause: The post build script should be placed after the web application targets are imported in your project file. The macros for the website output directory isn't populated before those targets have been imported, so usually it's best to put this operation in the bottom of the project file.

    Best,
    Rune

  4. rune closed this discussion on 06 Mar, 2017 07:32 PM.

Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac