How to edit a node module installed via npm?


Question

I'm using the node_swiz module, which in turn uses the validator module.

I want to make changes to the validator module, but I used npm install to install the modules/dependencies.

Can I just make changes to the validator module inside of node_modules, or will that node_modules dependencies be re-created and the latest version gotten when I publish to heroku or next time I run npm install?

The structure looks like this:

myNodeApplication
  - node_modules
     - swiz
         - node_modules
            - validator [this is the library I want to edit]

Thanks for the help!

1
89
11/9/2012 12:08:51 AM

Accepted Answer

You can edit the file directly, but this would be overwritten whenever npm updates, the best thing to do is go straight to the source.

If the changes affect functionality of the overall module, and may be useful to others, you may want to contribute to the original source on github and look for the change to be implemented.

If this is proprietary functionality that is needed, and would not help the development of the module, the best thing to do is fork it from github and make your changes. You can install items directly from github using NPM, and this method would let you integrate future changes in to your custom version from the original source.

To install directly from github, use the following command:

npm install https://github.com/<username>/<repository>/tarball/master

191
4/6/2014 2:30:42 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon