How to import and use a modified npm library packages dynamically

335 Views Asked by At

I am using a sigmajs library for creating node based graph visualisations. But the library package had a few bugs, so I modified a few files in the source code of the library and fixed them.
I have hosted my graphs on django server, and whenever I host it, the sigma package in the package.json gets loaded dynamically each time. The static library files on my machine which I had modified and fixed bugs don't get loaded. So,I get the same old package and not the modified one.
How do I access the modified library package dynamically when I host the server.

1

There are 1 best solutions below

0
On

My advice is that of copying your fixed version of the library on server and install it from local path instead of remote npm repository like this:

npm install --save /path/to/fixed/lib/dir/in/server.

See this answer: npm local install

Pay attention that your fixed lib won't be sync with official one.

I don't know how you modify the library but i suggest to fork the official repository and syncronize your local one with remote one as for example explaind here sync forked repo github.

In this way you can sync to official repo while you mantain your fix and you will install your modified local one. Eventually consider to open issues and PR on sigmajs official repo to apply your fix directly to official library. If they will be accepted you can then install directly official version.