Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install from the parent directory

I have a directory structure like this: /a/b/c

Directory c contains package.json and should contain node_modules.
How can I execute npm install from inside directory a?

I tried this way: npm --prefix b/c install b/c but this way, all the symlinks are created directly inside c instead of the default node_modules/.bin.

Is there any way to achieve that?

node: 6.2.2
npm: 3.10.2

like image 982
Zygimantas Avatar asked Jun 29 '16 19:06

Zygimantas


1 Answers

Using an npm pre install hook in a package.json within your a directory is likely the best choice in this situation.

scripts: {
    preinstall: `cd b/c && npm install`
}

This way running npm install in directory a will also do the c directory install and provide a seamless dev experience.

like image 168
Ian Belcher Avatar answered Sep 22 '22 00:09

Ian Belcher