I published my module to the NPM registry. When I installed it using
npm install --save-dev X
I see that the node_modules folder was included in the install, such that when I go to project Y which depends on X, I see:
Y/node_modules/X/node_modules
How is this possible?
My .npmignore file in my X project is as follows:
.idea
node_modules
bower_components
internal-docs
Anyone know what could be up?
You don't need to add node_modules
to your .npmignore
; it is ignored by default :
Additionally, everything in
node_modules
is ignored, except for bundled dependencies. npm automatically handles this for you, so don't bother addingnode_modules
to.npmignore
.
The npm install
command will naturally install the package's dependencies that are listed in its package.json
file. It is a normal part of the npm install
process to install the whole dependencies tree, otherwise the package wouldn't really work.
If you want to be really sure, you can use the npm pack
command to generate a tarball (similar to a zip file) that you can inspect and see what files are actually published when you run npm publish
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.