Sometimes it's easier to maintain a fork of a node package for your module, I'd like to be able to edit a module that's in node_modues
that I've installed via npm install githubaccount/myrepo.git
.
Currently any changed that I made to a file I have to copy back to the repo. This is tedious.
How can I edit modules in npm and have them tracked by Git?
Python's pip
has an option where you can define an 'egg' which symlinks a clone of the repo to the site_packages folder. I know it's a different system, but I've found it really quite useful in the past.
You can use the
npm link
command to do this. Here's how to use that. Let's assume that your npm module is located in~/npm-module
and your project using the npm module is in~/my-project
.The first call to
npm link
will create a link in npm's cache directory pointing to your local clone of the npm-module. The second call will link it into the project that's using the module (into thenode_modules
folder).If you take a look at your project's
node_modules
folder, you will see that it now contains a symbolic link to thenpm-module
's sources. Any changes you make in that folder will also be in the cloned project. You can commit changes there and push them back to your remote.This is similar to what you do with Python's
egg
feature.Here's the npm link documentation.