Reputation: 185
I need to use a 3rd party npm module, it's very old, I cannot directly use it with npm i
and reqiure
, I have to modify some source code of this npm module for my special use case.
So I'm thinking to clone the source code of the npm module to my source code base, and use it directly.
As the npm module is not a pure JS module, it contains some C code. I have no idea how to do this.
Could you give me some guidance?
For example, let's say the 3rd party npm module is request
, so generally I just npm i --save request
and then in my code I can use it like this
const request = require('request');
Since what I want is to modify some request code, so I will download request source code from https://github.com/request/request
, and maybe put the lib
folder into my project's root.
Then how can use request
from this lib
folder?
request
includes some c
code, how can I use it from lib
again?Upvotes: 2
Views: 1860
Reputation: 5622
You can install from a local folder where you have done the modifications
npm install /path-to-local-folder
To get this into package.json use
"dependencies":
{
"mymodule": "file:./path-to-folder",
"request": "^2.5"
}
Upvotes: 2