简体   繁体   English

node_modules目录包含在发布到NPM注册表的模块中

[英]node_modules dir being included in module published to NPM registry

I published my module to the NPM registry. 我将模块发布到NPM注册中心。 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: 我看到安装中包含了node_modules文件夹,因此当我转到依赖X的项目Y时,我看到:

Y/node_modules/X/node_modules

How is this possible? 这怎么可能?

My .npmignore file in my X project is as follows: 我的X项目中的.npmignore文件如下:

.idea
node_modules
bower_components
internal-docs

Anyone know what could be up? 有人知道会发生什么吗?

You don't need to add node_modules to your .npmignore ; 您不需要将node_modules添加到您的.npmignore ; it is ignored by default : 默认情况下将忽略

Additionally, everything in node_modules is ignored, except for bundled dependencies. 此外, node_modules所有内容都node_modules被忽略,但捆绑的依赖项除外。 npm automatically handles this for you, so don't bother adding node_modules to .npmignore . NPM自动为您处理此,所以也懒得添加node_modules.npmignore

The npm install command will naturally install the package's dependencies that are listed in its package.json file. npm install命令自然会安装在package.json文件中列出的软件包依赖项。 It is a normal part of the npm install process to install the whole dependencies tree, otherwise the package wouldn't really work. npm install过程的正常部分是安装整个依赖关系树,否则该软件包将无法正常工作。

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 . 如果确实需要确定,可以使用npm pack命令生成一个tarball(类似于zip文件),您可以检查它并查看在运行npm publish时实际发布了哪些文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 告诉npm在其他目录中查找node_modules - Tell npm to look for node_modules inside a different dir 已安装 npm 包,用于 node_modules 目录中存在的依赖项和 devDependencies - Are installed npm packages for dependencies and devDependencies present in node_modules dir npm config设置注册表 <registry url> -我们可以使用注册表指向本地的node_modules文件夹吗 - npm config set registry <registry url> - can we use registry to point to local node_modules folder NPM 模块在 /node_modules 文件夹中但找不到? - NPM module Is In /node_modules folder but cannot be found? npm:找不到node_modules中存在的模块 - npm: cannot find module which exists in node_modules npm安装时忽略node_modules中的自定义模块 - Ignore a custom module from node_modules when npm install npm不安装node_modules - npm not installing node_modules NPM:无需转译即可在node_modules目录中编辑es6书面插件 - NPM: edit es6 written plugin in node_modules dir without transpiling npm安装在不在node_modules /中的模块上 - npm install on modules not in node_modules/ 错误:尝试运行 npm 时找不到模块“C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js” - Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js' when trying to run npm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM