How to edit NPM package code?


#1

I’ve found a bug in one of the NPM packages and it should be easy to resolve, but I’m wondering how I could do that in Meteor, and if it would affect the Meteor deployment on Galaxy?

It seems if I edit any code in the node_modules folder, the changes do not apply. I’m also concerned if the edits I do will be uploaded when deploying.

Any advice?


#2

The change you do in your local node_modules folder won’t affect the production environment because when you deploy the app, based on your package json, the buggy version will be installed anyways. Also I think you cannot and you should not directly edit something inside node_modules.

You can create a Pull Request if you are sure that there is a bug. But let’s be honest, based on the community that maintains the package, your PR might take quite some time to be approved and released. So in the meantime here are my findings what you can do to overcome your problem

  1. Monkey Patching => I think generally not recommended but if you must you can take a look at the following this one and that one or investigate further

  2. Fork the package, do the change and use your own copy => So the idea is, instead of referring this module, after forking and editing the code, you can refer your forked package, there is a step by step guide that you can check

As I mentioned, these are my findings but let’s see what more experienced guys would suggest :slight_smile: