Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

node.js - How to edit a node module installed via npm?

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!

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/<branch>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...