Use 'npm link' to edit an Node.js npm module locally
Use case:
Say you are running a node app, and you think the NPM module you're using is causing a bug. What's the easiest way to dive in and edit the module? Here's how...
We'll assume that the module with the bug is Express.
The steps
Navigate to the npm module folder (
app_name/node_modules/express/
).-
Then create a global symlink to that npm module.
npm link
Navigate back to your project folder (
app_name
)-
In your project folder, now reference that symlink.
npm link express
Next
Now every time you edit anything in appname/nodemodules/express, you just need to refresh to see the effects in your app. No need to rebuild, or npm anything.
When you've verified it works, you can check it in to github or whatnot. This makes testing locally nice and painless.
Sources:
https://npmjs.org/doc/link.html
Written by Jamis Charles
Related protips
1 Response
Does not work: "Link target resolves to the same directory as link source"