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.
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:
# CD to the forked-library project
cd ~/forked-library
# Call npm link to create a global link
npm link
# CD to the test project
cd ~/test-project
# Call npm link to link the development version to this project
npm link forked-library
After doing that, you should have a symbolic link to your local forked-library
folder from the test-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.
Although nwinkers solution is more convenient I am posting this as an alternative:
- Push your
forked-library
changes to GitHub.
- In your 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
.
- Change the version of the
forked-library
in your text-project
's package.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
in test-project
and work against the patched lib.