I am a noobie with all this Github forking-pull-request lifecycle. What I want to do is fork a repository, make some changes and try them on a project before submitting a pull request.
I already forked the repo and modified it but I am not able to test it.
Let's suppose I increased the version of the forked library in package.json to 1.0.1. Then I execute npm install -g
.
Now I want to test it in another test-project
, so I update the package.json devDependencies info with the new fixed version of the library (1.0.1).
Now I run npm install
in test-project
but I get this error:
npm ERR! version not found: forked-library@1.0.1
I was expecting that since I installed it globally, this project would resolve it from my local npm cache (where I can see the 1.0.1 version), but it seems to be looking for it in the npm online repository.
Although nwinkers solution is more convenient I am posting this as an alternative:
forked-library
changes to GitHub.forked-library
page, at the right side, get the URL pointed at by the Download ZIP button, replace archive for tarball and remove the .zip extension. For instance:https://github.com/somebody/forked-library/archive/master.zip => https://github.com/somebody/forked-library/tarball/master
.forked-library
in yourtext-project
'spackage.json
to point at the modified URL you got in step 2:https://github.com/somebody/forked-library/tarball/master
Now you can do
npm install
intest-project
and work against the patched lib.The
npm install
command will always try to find a released version from the npm registry. Since you're still in development, it will not find it there.To work around this, you can use the
npm link
command - which will set up a symbolic link to your local development version.Here's how to use it:
After doing that, you should have a symbolic link to your local
forked-library
folder from thetest-project/node_modules
folder.This will allow you to use the development version without releasing it. You can make changes in the forked library and they will be visible immediately in your test project.
Here's the npm link documentation.