Search code examples
node.jsnpmcdnpm-install

How to run npm install without changing working directory


How to install dependencies for project without changing working directory to project root?

Curently you need to execute:

cd /my/project/root && npm install && cd -

I'm looking for an option like -C for Makefile so that I can:

npm install -C /my/project/root

Any ideas on how to accomplish this?


Solution

  • A colleague of mine has found a way to do this (note that this is not documented in npm help but online):

    npm install --prefix /my/project/root
    

    Or the short version (only documented online)

    npm install -C /my/project/root