Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm publish ignores files inside node_modules

I've created npm package. In this package I'm using some modules which I put to node_modules to be able to require them as "modules", for example I have modules node_modules/my-module.js which I require in my code as require('my-module'). Now I do "npm publish" and then in another project I do "npm i" to install my module. It is installed but there are no my modules which I put to node_modules. I tried to add the next lines to .gitignore and to .npmignore, but it did not help:

node_modules/*

!node_modules/my-module.js

what do I do wrong?

like image 555
pavel06081991 Avatar asked Jan 07 '23 21:01

pavel06081991


1 Answers

I believe that all files in node_modules/ are ignored by NPM, so setting rules for node_modules in .gitignore and .npmignore will have no effect.

Additionally, everything in node_modules is ignored, except for bundled dependencies. npm automatically handles this for you, so don't bother adding node_modules to .npmignore.

Source

like image 68
gauge Avatar answered Jan 14 '23 11:01

gauge