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://git@github.com/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!
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.