Home >Common Problem >Where is the default installation location for npm packages in Windows 10?
Directory path to the NPM package installed locally for a specific project on Windows:
Those interested in installing the package using npm can do so after navigating to their project directory. Run the given command from the command prompt.
npm install package-name
When we execute the above command, it will download the specified package and all required dependencies from the npm registry to install into the node named node_modules folder. This will be created in the current project's working directory.
For exampleSuppose we are building some Node.js application and our project directory name is: my-first-app.
Then first we use the command prompt to switch to the directory and then install some software packages, say – Go.
npm install go
The above command will download and install the Go package from the NPM registry, located in a folder named node_modules–, located at We now install it in the same directory.
Also , if your project depends on multiple modules, then the packages and dependencies they require will also be installed by npm, but node_modules A nested folder structure environment within a directory, where each package is installed in its folder.
For example , if your project depends on the "express" module, which further requires a body parser module, then ## The folder structure of the #node_modules directory will look like this:
node_modules├── express│ ├── index.js│ ├── ...│ └── node_modules│ ├──body-parser│ ├── index.js│ └── ....└── go├── index.js├── ...└──binAs you can see, each package has its directory and any dependencies it requires are installed in a sub-section called node_modules in the directory.
For the globally installed NPM package directory on Windows 10 or 11
Sometimes we need to install some NPM packages, not for a specific local project, butInstall globally so that multiple projects can benefit from it. This saves developers from having to install common packages needed across multiple projects again and again.
To install an NPM package globally, we just need to add the-g flag to its regular installation command, this is the syntax:
npm install -g <package-name>When you
install globally When a package is installed, it is stored in a different location on our file system rather than in a specific folder within the project.
On Windows,npm stores globally installed packages in a directory – C:\Users\your-username\AppData\Roaming\npm. Change
your usernamewith the current user. Under the NPM folder you will see a directory –
node_moduleswhere you can find all npm installed packages on Windows 10 or 11.
In short, when you install a package locally, npm will install the package in the node_modules directory located in the current working directory of the command prompt. And when you
globallyinstall a package, npm will install it in the %AppData%\npm\node_modules directory. The location of npm packages helps manage Node.js projects and dependencies.
The above is the detailed content of Where is the default installation location for npm packages in Windows 10?. For more information, please follow other related articles on the PHP Chinese website!