Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run npm from subdirectories on Heroku

I have a project which contains 2 subprojects:

  • First is the API
  • Second is the client

And both of these projects have their own dependencies mapped in their own packages.json files, which is placed in each subdir.

So the question is how to run npm install from sub directories on heroku?

I tried putting something like this in the main npm file

"scripts": {
    "postinstall": "cd my_subdir; npm install"
}

But it doesn't work, showing can't cd to my_subdir

like image 744
Ph0en1x Avatar asked Dec 22 '13 01:12

Ph0en1x


1 Answers

Utilize npm's --prefix option:

"scripts": {
  "postinstall": "npm install --prefix ./my_subdir"
}
like image 136
Troy Avatar answered Sep 21 '22 02:09

Troy