bitten bitten - 2 months ago 10
Bash Question

Trigger `npm install` for a certain directory in a shell script

I'm in a shell script running in

~/folder1/
and I'd like to trigger
npm install
in
~/folder2/
. Is it possible to do this?

Answer

You can use the --prefix option:

npm install --prefix ~/folder2/ packagename 

You just have to omit the packagename to install from the package.json

npm install --prefix ~/folder2/