I have a web app: fooapp. I have a package.json
in the root. I want to install all the dependencies in a specific node_modules directory
. How do I do this?
Lets say I have two widget
dependencies. I want to end up with a directory structure like this:
node_modules/
widgetA
widgetB
fooapp/
package.js
lib
..
when I run npm install fooapp/
I get this:
node_modules/
fooapp/
node_modules/
widgetA
widgetB
package.js
lib/
..
fooapp/
package.js
lib/
..
npm makes a copy of my app directory in the node_modules dir and installs the packages inside another node_modules directory.
I understand this makes sense for installing a package. But I don't require()
my web app inside of something else, I run it directly. I'm looking for a simple way to install my dependencies into a specific node_modules directory.
This question is related to
deployment
node.js
dependencies
npm
In my case I need to do
sudo npm install
my project is inside /var/www so I also need to set proper permissions.
Just execute
sudo npm i --save
That's all
Source: Stackoverflow.com