is there any way to route npm install to a specific part of hard drive and when i do npm install it make node_module folder in that part of drive, and when i run any project it look for dependencies in that part of drive, just like single pool for every project.
then if i have two projects with similar dependencies then i only need to npm install
in one project so dependencies become available in pool, and no need to do npm install
in another project just npm start
Thank you, Inzamam Malik
Please reserve at least 6 GB for OS resources and npm On-Site appliance containers.
It is not necessary to do "npm install" each time you want to compile. You just need to do it when you change the dependencies of your project.
If you find that npm is running slow and it isn't your computer or internet, it is most likely because of a severely outdated version.
You can achieve something close to what you are describing with the link
option.
From https://docs.npmjs.com/misc/config#link:
If true, then local installs will link if there is a suitable globally installed package.
Note that this means that local installs can cause things to be installed into the global space at the same time. The link is only done if one of the two conditions are met:
- The package is not already installed globally, or
- the globally installed version is identical to the version that is being installed locally.
So you will still have some files in each project's node_modules
, but you shouldn't have as large a folder.
To turn this behavior on, run:
npm config set link -g
Edit: There is no way you can avoid running npm install
and having a node_modules
folder. Node.js always looks in node_modules
for dependencies (this behavior pre-dates npm
itself). The link
option will make npm
create symlinks in node_modules
, pointing to a common pool. That will reduce disc usage, but you cannot do away with node_modules
.
You can use PNPM Package manager, It uses a global pool for dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With