gpt4 book ai didi

npm 正在以一种奇怪的递归方式安装依赖项

转载 作者:行者123 更新时间:2023-12-04 05:31:30 24 4
gpt4 key购买 nike

我用了npm install --dev安装 package.json 中列出的依赖项文件,似乎不是以平面结构安装所有包,而是在模块目录中安装每个模块的依赖项。

我不得不取消它,因为它需要很多时间,因为许多依赖项应该已经得到满足,但它必须在不同的嵌套目录中重新下载它们(我希望没有循环,它最终会完成)。 ..

使用树命令这是我得到的一个例子:

├── grunt-cli
│   └── node_modules
│   ├── findup-sync
│   │   └── node_modules
│   │   ├── glob
│   │   │   └── node_modules
│   │   │   ├── minimatch
│   │   │   │   └── node_modules
│   │   │   │   ├── lru-cache
│   │   │   │   │   └── node_modules
│   │   │   │   │   └── weak
│   │   │   │   │   └── node_modules
│   │   │   │   │   └── mocha
│   │   │   │   │   └── node_modules
│   │   │   │   │   ├── coffee-script
│   │   │   │   │   │   └── node_modules
│   │   │   │   │   │   └── jison
│   │   │   │   │   │   └── node_modules
│   │   │   │   │   │   └── browserify
│   │   │   │   │   │   └── node_modules
│   │   │   │   │   │   ├── browser-resolve
│   │   │   │   │   │   │   └── example

任何想法为什么会发生这种情况?

最佳答案

别担心,这实际上是 Npm 的设计方式。您甚至可能会看到多次安装相同的模块(尽管通常使用不同的版本)。

这个想法是,安装在 node_modules 下的每个模块都是该模块的某种独立安装,具有其依赖项和必要的版本——它不依赖于全局安装的模块。

如果您担心多次安装模块效率低下,实验性 npm dedupe .

关于npm 正在以一种奇怪的递归方式安装依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18241258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com