Replacing a default Express/Connect JS file with customized source code

93 Views Asked by At

I modified JS source files in my_server_root_folder/node_modules/express/node_modules/connect/lib/middleware/. I would like to make a copy of the custom file and use my version instead of the one installed by npm in the path I mentioned above. If I make a copy of the 'connect' module and install it in my_server_root_folder/node_modules/connect how do I direct Express to use that module instead of the one installed in my_server_root_folder/node_modules/express/node_modules/connect?

1

There are 1 best solutions below

0
On

you could use symbolic link

ln -s target_path link_path

this way you can only maintain 1 version of the modified file, and link to it from other locations;

second approach is to clone Connect, make all necessary changes to it, and reference your cloned version in you projects.