schabluk
schabluk

Reputation: 708

npm installs packages and dependencies in the project root directory

I switched from Windows to Mac. When I'm trying to install npm modules, the packages and their dependencies are created inside the project root directory.

On Windows the module was installing into ./node_modules, with all dependencies inside module folder.

Is there something I need to configure to make it work as before?

edit

I have both, node_modules folder and package.json in my project dir:

{
  "name": "react",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "chokidar": "^1.0.3"
  }
}

And still, chokidar package and its dependencies are in the project root.

Upvotes: 3

Views: 5358

Answers (1)

Pierre Inglebert
Pierre Inglebert

Reputation: 3930

When you use npm install, it will get up until it finds a package.json or a node_modules folder and install your package there.

So if your project structure is like this

project_root/
  modules/
    mymodule/
  node_modules

And you run npm install in mymod directory, the module will be installed in project_root/node_modules

Upvotes: 0

Related Questions