基本 npm + Webpack:为什么有这么多模块?
Basic npm + Webpack: why so many modules?
我只是在涉猎 npm 和 Webpack 以试图了解它们是如何结合在一起的。我创建了一个非常简单的 package.json 文件并要求 npm 像这样安装 webpack:
npm install webpack --save-dev
但是当我这样做时,我的 npm_modules 文件夹中充满了 127 个模块:align-text、ansi-wrap、crypto-browserify、optimist、punycode 等。当我使用 "npm install" 在其他使用Webpack的项目中,好像没有这个问题。他们只有列为 devDependencies 的依赖项。
如果我还添加 webpack-dev-server,列表会增长到 192!
如果模块不干扰,它不会干净,但不会有真正的问题。但是我正在尝试安装 webpack,因为我想包含我的模块,一旦 webpack 看到 node_modules 目录,它最终会产生一个超级大的输出:(
这正常吗?有什么办法可以减少模块数量吗?
对于我糟糕的英语,请接受我的道歉,非常感谢您发送的任何建议。
因为 npm@3 依赖项现在是 installed flat。
您可以通过查看您提到的 "other projects" 的 node_modules/webpack/node_modules
内部来验证这一点。在那个文件夹里面,
你应该也找到 webpack 的依赖项。
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.
我只是在涉猎 npm 和 Webpack 以试图了解它们是如何结合在一起的。我创建了一个非常简单的 package.json 文件并要求 npm 像这样安装 webpack:
npm install webpack --save-dev
但是当我这样做时,我的 npm_modules 文件夹中充满了 127 个模块:align-text、ansi-wrap、crypto-browserify、optimist、punycode 等。当我使用 "npm install" 在其他使用Webpack的项目中,好像没有这个问题。他们只有列为 devDependencies 的依赖项。
如果我还添加 webpack-dev-server,列表会增长到 192!
如果模块不干扰,它不会干净,但不会有真正的问题。但是我正在尝试安装 webpack,因为我想包含我的模块,一旦 webpack 看到 node_modules 目录,它最终会产生一个超级大的输出:(
这正常吗?有什么办法可以减少模块数量吗?
对于我糟糕的英语,请接受我的道歉,非常感谢您发送的任何建议。
因为 npm@3 依赖项现在是 installed flat。
您可以通过查看您提到的 "other projects" 的 node_modules/webpack/node_modules
内部来验证这一点。在那个文件夹里面,
你应该也找到 webpack 的依赖项。
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.