Home > Net >  Do I need to reinstall a package that I have already installed before on another project?
Do I need to reinstall a package that I have already installed before on another project?

Time:10-04

I don't know if I do this right or wrong and will eat up my space.

I know that when you install a package using npm install or yarn add it will add to %AppData%/Roaming/npm on Windows and on my node-modules folder in my project. But if I already have packages that have been installed before and save to my %AppData% do I need to install them again on other projects?

Or is there a way that I can call the package inside %AppData% without install again?

And if I install again wouldn't it create another copy of the same package?

CodePudding user response:

Basically, every node project has its own dependencies as described inside the project's package.json file under the dependencies/devDependencies entries.

Whenever you run npm install inside your project root folder (where the package.json is located) it will be installed inside the PROJECT/node_modules folder.

Yes, you may have the same packages installed on your local machine but they belong to different projects.

To make it clear, consider one project uses a package in version 1.0.0 and another project uses the same package in version 2.0.0.

Some NPM packages can be installed globally on your machine for global usage. Usually, these packages are CLI tools like gulp, create-react-app, lerna etc.

  • Related