I am trying to test a branch of a local module in a separate project.
Normally, I npm link
the local module to my dev environment. The module link is always on the master. I'd like to have separate branches and npm link
a specific branch of the module in a separate project.
I tried using some syntax in this post such as npm link modlue#nameOfBranch
I know you can install a specific git branch from GitHub based on the npm
docs. But ideally, I would like to work on the modules branch, make updates, then have those changes instantly reflected via the npm link
in my working project.
Example: Let the local-dir is the local directory and project-dir is the project directory and local_module is the local module package you want to install, first go to the local-dir and type npm link and next go to the project directory and type npm link <local_module> this will link your local module to your project.
The npm installation from GitHub is quite useful for testing packages. It also gives the flexibility to install any specific branch, version, tag, and so on.
If I understand your question correctly then you are already having a project say project_1
which is using another local project say project_2
as a dependency using npm link
. Now you are trying to create another new project say project_3
which would be using project_2's
different branch as a dependency. You don't want your project_1
from using project_2's
master as a dependency.
The best solution can think of is creating another new project which would be the replica of project_2
name it as project_2'
and then start working on a different branch and use npm link
to use it as dev dependency. So whenever you update it locally you can find the changes without having to update it.
You cannot work with the same project_2
because once you check out the branch then git changes at the file system level. No two projects can work with different branches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With