I am learning NodeJS and Electron app dev and currently every sample app I work on has me run the command npm install which results in the node_modules downloading to the project folder. This results in a really large amount of disk usage as many app use the same node modules over and over.
Is there a way to install all the required node modules for all projects to a central location and make them all use that 1 source of modules?
Another concern of mine. If the Electron apps I am building are packaged as an install-able .exe file. Will they be able to package the functionality needed from those global Node packages wwhen the app is ran on another users PC?
There are two ways to install npm packages: locally or globally.
To download packages globally, you simply use the command npm install -g
This is recommended if you want to use module as a command line tool.
You can always use:
npm link (in package dir) and npm link [<@scope>/]<pkg>[@<version>] which will install module on your disk only once and every additional time will just make symlink to that module.
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