Let's say there is an npm package called abcd
. Normally in package.json
, we specified the dependencies as "abcd": "^1.0.0",
But this abcd
does not work as expected, so I forked (and modified) it inside https://github.com/mygithubid/abcd
Then I run npm install git+https://[email protected]/mygithubid/abcd.git
and in package.json
, the definition is changed to "abcd": "git+https://github.com/mygithubid/abcd.git",
After restarting the project that using this abcd
, now it throws error Module not found: Can't resolve 'abcd'
... even though I saw the abcd
folder is added inside node_modules
Could you advise the mistake I made in above? Thanks!
Use npm list [package-name] to know the specific latest version of an installed package. Use npm install [package-name]@[version-number] to install an older version of a package. Prefix a version number with a caret (^) or a tilde (~) to specify to install the latest minor or patch version, respectively.
One fairly clean option is to use patch-package
: https://www.npmjs.com/package/patch-package
If the people using your project might use either npm or yarn, then remeber to make the patch available for both. More info under patch-package --use-yarn
.
Patch or fork? See https://www.npmjs.com/package/patch-package#benefits-of-patching-over-forking
Be sure that the github repository contains compiled files, at most cases you need build the package for npm first, the compiled files push only to NPM. To find out how to build the package check the package.json file
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