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

查看:30
本文介绍了如何编辑通过 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 中的验证器模块进行更改,还是会重新创建 node_modules 依赖项并在我发布到 heroku 或下次运行 npm install 时获取最新版本?

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 中 fork 并进行更改.您可以使用 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///tarball/

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

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