How to make node_modules folders common with symbolic links

During development, especially when using tools such as gulp to progress multiple projects, node_modules folders exist for each project, using a lot of disk space. One way to solve this problem is to use a common node_modules method.

Specifically, symbolic links can be used to make node_modules common. A symbolic link is a link that allows a file or directory in one location to be referenced as if it were in another location.

To create a symbolic link on a Mac, do the following

ln -s /Users/xxxx/node_modules . /node_modules 

This command will create a symbolic link named node_modules in the current directory, pointing to /Users/xxxx/node_modules.

This way, node_modules can be shared among multiple projects, saving disk space. However, care should be taken when using different versions of modules in different projects, for example.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top