Home > Common Problem > body text

Where is the default installation location for npm packages in Windows 10?

WBOY
Release: 2023-09-18 11:25:01
forward
1906 people have browsed it

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
Copy after login

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
Copy after login

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.

Windows 10 中 npm 软件包的默认安装位置在哪里?

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├── ...└──bin 
Copy after login

As 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, but

Install 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>
Copy after login
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 username

with the current user. Under the NPM folder you will see a directory –

node_modules

where you can find all npm installed packages on Windows 10 or 11.

Windows 10 中 npm 软件包的默认安装位置在哪里?
Windows 10 中 npm 软件包的默认安装位置在哪里?
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

globally

install 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!

source:yundongfang.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template