I have a list of websites like this:
project1/site
project2/site
project4/site
...
projectN/site
Each site
folder has inside node_modules
folder, gruntfile.js
file and a package.json
file. So they look like this:
project1/site/gruntfile.js
project1/site/package.json
project1/site/node_modules/
...
projectN/site/gruntfile.js
projectN/site/package.json
projectN/site/node_modules/
Everything is working fine with my tasks, plugins and stuff.
I am wondering if I can work this out with just one node_modules
folder on my root folder as my websites are using similar tasks.
project1/site/
project2/site/
...
projectN/site/
/node_modules/
Is this even possible? What do I need to do?
You can use the -g
flag with npm
to install modules globally, as in: npm install -g <modulename>
This will install all the modules so they are accessible to all your node projects.
And then you can create a link for each of the projects to the required modules using npm link
, as explained in the link @jakerella referred to :
...there are some cases where you want to do both. Coffee-script and Express both are good examples of apps that have a command line interface, as well as a library. In those cases, you can do one of the following:
- Install it globally, and then npm link coffee-script or npm link express (if you're on a platform that supports symbolic links.) Then you only need to update the global copy to update all the symlinks as well.
See the npm documentation .
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.