0

I have added libraries to my Angular Project with the following syntax, for example:

npm i leaflet-easybutton

When I noticed after incorporating it, the library didn't have all the functionality I wanted, I was successfully able to edit parts of the code, in the following path, to enhance it the way I wanted and all was good!

..\node_modules\leaflet-easybutton\src\easy-button.js

Sometime later, after updating several parts of my Project, the code I enhanced no longer worked, so when I made changes to the file mentioned above, they were not reflecting when I tested the Project. I tried to debug my new changes, but the code would never reach that spot. Very strange!! I removed the easy-button library and then reinstalled a fresh one, but that also had no effect. It was stuck calling my old code, but I didn't know how or where?

I was eventually able to track it and debug it; its in a webpack? So despite removing my old library and installing the latest fresh new version, I cannot get my Project to stop using my old version in the webpack. I don't even know where this webpack is?

I run my project with npm start i.e. ng-serve.

My question: how can I update the files in the webpack to re-incorporate my new files? Is there something I am missing? I was not able to find an answer in this forum, or elsewhere?

Thanks, Moa

Moa
  • 125
  • 1
  • 7
  • Files inside node_modules should be changed. It's how things work in node.js. If the library license allows you may fork a library, make changes you want and publish it and install it. Or you may copy a dist of the library from node_modules to a project folder (./vendors/your-changed-lib) and change the package.json dependency for that lib to get it from the folder and not from npm. "original-lib": "file:vendors/your-changed-lib" – Oleksandr K Mar 19 '23 at 11:52
  • My problem is now that I have removed the Library and reinstalled its latest version, my project is not picking it up. Its still using the old one in the webpack and I don't know how to reset it so I can reference the new Library. – Moa Mar 19 '23 at 23:50

1 Answers1

0

I solved it finally.

I deleted my .angular/cache folder and then right after restarted with ng serve as per NJS in Clearing Webpack cache.

Thanks for the efforts.

Moa
  • 125
  • 1
  • 7