How to install npm packages to a specified directory
Learn, how to install npm packages to a specified directory in your project.
Normally, when we run an npm install package-name
command, npm will install the packages in a default directory (node_modules folder).
To install the packages into a specified directory, we need to use the --prefix
option followed by the directory path.
Example:
npm install --prefix ./my-app react
This above command will install a react
package into the my-app
folder.
Note: If the specified directory doesn’t exist, npm will create it automatically.