为什么我创建的 npm 包在作为另一个模块的依赖项安装时其中有一个 node_modules 文件夹?

Why does the npm package I created have a node_modules folder in it when installing it as dependency for another module?

我刚刚发布了我的第一个 npm 包。当我在我的项目中安装包作为依赖项时,我打开 node_modules 中的项目文件夹,看到它还有一个 node_modules 文件夹和一个包,文件夹中 history 。我的项目没有任何常规依赖项,只有 devDependencies,所以我不明白为什么会这样?您可以查看我的 package.json 文件并尝试从 github 页面安装模块 https://github.com/danielyaa5/react-contextulize

运行 npm install 会在很多情况下安装devDependencies

尝试在生产模式下明确安装:

npm install --only=production

这是一个包含更多信息的related answer