How do I work on an npm package that is in use


I am new to git-flow

I am currently making branches and PR’s for an npm package that I’m using in my react-native project.

I’ve cloned this in a seperate folder to my node_modules so I have two versions.

Can I use the version in node_modules for development while it is live? I’m using git-flow, would it be a case of switching to the master branch when I publish my app, and use develop/ branching while I make changes?

Most of the time, npm modules (or any kind of reusable code blob like them) are versioned so that you don’t have to jump through hoops like you’re describing. So if Project A is dependent on Module B and A needs a new feature added to B, then one would:

  1. Add the new feature to Module B
  2. Release a new version of Module B (hopefully following semver principles)
  3. Update the version of Module B in Project A (by updating your package.json or running npm update module-b if the new version is applicable to the version range already)

This way, you’re never working on the npm module that is “in use”. You work on each project separately, even if you’re switching back and forth between them.

I hope that helps!