简体   繁体   中英

Why the express module is not installing in its default directory e.g., npm\node_modules?

I'm trying to install express module using the following commands:

npm install --save express
npm install -g express
npm install -g express-generator

After installation I was expecting the module to be created inside nodejs\\node_modules\\npm\\node_modules , Instead it is getting installed and created in somewhere else (In C:\\Users\\$SudoName\\AppData\\Roaming\\npm\\node_modules ).

Therefore while running the project node is unable to locate the express module in it's own directory where it suppose to be.

Let's explain your commands step by step:

$ npm install --save express

The --save command is used when you want to save a package for distribution. This command saves the package under your dependencies section of your package.json file.

$ npm install -g express

From the documentation : "In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.".

In your case: C:\\Users\\$SudoName\\AppData\\Roaming\\npm\\node_modules

Note : You can see where your packages are installed using:

$ npm list -g

Finally,

$ npm install -g express-generator

gets the same approach. It gets installed under your global dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM