Ignore a custom module from node_modules when npm install

Viewed 1864

I have 4 modules inside node_modules folder where one of them is a custom module. In my package.json file, I have the other 3 modules specified as dependencies. So now when I do npm install node is removing that one custom module from node_modules folder because it is not listed in dependencies inside package.json file.

Is there anyway to keep this custom module without node deleting it when I do npm install? I've tried to include it in .npmignore file, but node is still deleting it.

1 Answers

Put your custom module to another directory outside the node_modules and add it to your package.json as a file reference.

"dependencies": {
    "custom-module": "file:custom-module"
    ...

Then you can run npm install and it will sort out your node_modules right.

Related