如何编辑通过npm安装的节点模块? [英] How to edit a node module installed via npm?

查看:107
本文介绍了如何编辑通过npm安装的节点模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用node_swiz模块,该模块又使用验证器模块.

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

我想更改验证器模块,但是我使用npm install来安装模块/依赖项.

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

我可以只更改node_modules内部的验证器模块,还是在发布到heroku或下次运行npm install时重新创建node_modules依赖关系并获得最新版本?

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?

结构如下:

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

感谢您的帮助!

推荐答案

您可以直接编辑该文件,但是每当npm更新时,该文件就会被覆盖,最好的做法是直接访问源代码.

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.

如果更改影响整个模块的功能,并且可能对其他模块有用,那么您可能希望对github上的原始源代码有所贡献,并寻找要实施的更改.

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.

如果这是必需的专有功能,并且对模块的开发无济于事,那么最好的办法是从github派生它并进行更改.您可以使用NPM直接从github安装项目,这种方法可以让您将将来的更改从原始来源集成到您的自定义版本中.

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.

要直接从github安装,请使用以下命令:

To install directly from github, use the following command:

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

这篇关于如何编辑通过npm安装的节点模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆