简体   繁体   中英

How to NOT use node_modules folder?

When I type npm install <PACKAGE NAME> , it saves the files in a folder called node_modules, and this makes the project very heavy (200-400 files).

I wonder how the global packages works? I mean, the first thing that comes to mind is that when we install a package globally, is that the node.js will add the dependency on package.json and when the program runs, it goes to a folder on the computer where the packages are installed and goes use them.

The way i'm doing, each project will have the entire library inside, almost as if I had cloned that library repository into my project.

Normally if you're using a version control system like git, you're supposed to have a .gitignore file where the node_modules will be ignored.

Meanwhile, if you're bothered about your local computer storage;

If your operating system is a Linux Distro try installing your packages globally so that all the modules will be stored in a single node_modules folder in the home directory. Do this using npm install -g package_name

If you're using windows this will help

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