Summary
I'm looking for instructions on how to get a github-fork of a node_module integrated into my project, so I can use the module with my own modifications to it, without touching code inside node_modules/xyz.
Details / example / reason:
As an example I have found that angular/cdk drag and drop is quite nice, but has flaws. So I needed to change the code in node_modules/@angular/cdk/esm2015/drag-drop.js (which I don't want to).
But also plotly (https://github.com/plotly/angular-plotly.js).
Mostly, like with the cdk/drag-drop there's a github repository with source code. And of course, changing sth. inside node_modules is ultra stupid and obviously I'd prefer to fork the repository instead and then link my fork in the package.json or so (?!).
That said...
I don't know how right now.
I could not find any docs or blogs on this topic. I guess I must be choosing the wrong keywords ??!
What I'd like to ask for
Could someone please give a link to a page that explains this process in great detail or at least summarize the important steps ?
What's on my mind so far...
Where to put the repository relative to my project, can/must it be in a parallel folder ?
In my main project how to link that new forked git module (is it in package.json ?)
Do I need to separately precompile that forked git module after every change ? Which commands ? Or is there an option so that my main module/project compiles each change through the ng serve watch as well on development ?
You have several options to use a dependency's fork in your Angular project:
Please check @Dino's answer.
package.json, import the fork like that: "dependency": "git+https://github.com/your-username/your-git-repository.git"node_modulesdirectorynpm i in your project againTo learn in detail how to import a GitHub repository as dependency, read also the official npm documentation.
cd fork-directorynpm loginnpm init
https://www.npmjs.com/package/your-package-name should return a 404 errornpm publishpackage.json, import the fork: "your-package-name": "package-version" (package-version is the version number of your npm package)npm i in your project againTo learn how to publish an npm package, read also this blog post and the official npm documentation.
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