An npm package I am using has been forked on github with some bug fixes and I now want to use the forked code in my project until the fork is merged.
In my package.json I change the reference in dependencies from e.g. “cool-package”: "^0.10.0" to “cool-package“: "git://github.com/developer-who-forked/cool-package.git" but this doesn’t work.
If I run npm install after updating the package.json and then go in to node_modules/cool-package/ I don’t see any /src folder or any /dist folder (all the other modules installed via normal npm seem to have at least a /dist folder).
I only see an /example folder and a /test folder alongside a package.json and a README.md. If i’d installed the package by including “cool-package”: "^0.10.0" there would be the src/ and dist/ folders.
The forked repo, or the original repo it was forked from don’t have a /dist folder - it is actually in the .gitignore file. So I think I am missing some build step that is required to create the /dist files when trying to access github repos directly in the package.json.
What worked for me was:
/dist
to ghnpm install {username}/{repo}.git
instead of manually adding the record to package.json
Just Answered the Question Based on Comments:
I run npm run-script build
and helped me!
Why it worked -
The issue when installing an npm package directly from a GitHub URL: the missing build step. When you install a package from npm, it's usually already built and compiled, meaning it has the /dist directory with the production-ready code. However, when you pull directly from GitHub, you're getting the raw source code, which often doesn't include the compiled /dist directory (as it's typically in .gitignore).
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