简体   繁体   English

为什么每次我使用 npm 或 yarn 安装 package 时,它都会安装所有依赖项?

[英]Why every time I install a package with npm or yarn it installs all the dependencies?

every time I install a dependency, for example yarn add socketio , instead of installing that dependency alone it installs all the ones from the package.json .每次我安装依赖项时,例如yarn add socketio ,而不是单独安装该依赖项,它会安装package.json中的所有依赖项。 Is there a way that I only install the dependency that I indicate and not all?有没有办法只安装我指出的依赖项而不是全部?

Checked with v1.22.0 .使用v1.22.0检查。

This should only happen if you have a package.json file and its dependencies are not installed.仅当您有package.json文件且未安装其依赖项时,才会发生这种情况。

Consider the example, where you have underscore as dependency in package.json and somehow it is not installed yet.考虑这个例子,你在package.json中有下划线作为依赖项,但不知何故它还没有安装。 Now, you're trying to install let's say color package.现在,您正在尝试安装颜色package。 In this case, yarn will install color as well as underscore as dependencies.在这种情况下,yarn 将安装颜色以及下划线作为依赖项。 But, once all the dependencies mentioned in package.json are installed, yarn will not install dependencies again.但是,一旦package.json中提到的所有依赖项都安装完毕,yarn 将不再安装依赖项。

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

相关问题 NPM安装会安装我的package.json中没有的依赖项 - NPM install installs dependencies that are not in my package.json Npm包依赖项无法安装 - Npm package dependencies not install 如何通过使用npm install或yarn安装仅具有自己版本的package.json依赖项 - how to install only package.json dependencies with their own versions by using npm install or yarn “npm install” 在 node_modules 目录中安装所有依赖项,而不是将它们嵌套 - “npm install” installs all dependencies in node_modules directory, instead of having them nested `npm install`通过网络安装我项目的所有依赖项,即使它们已经安装或可以从缓存中获取 - `npm install` installs all dependencies of my project over the network, even if they are already installed or available from cache 如何将我通过npm安装的所有依赖项保存到我的package.json文件中? - How do I save all the dependencies I install through npm into my package.json file? 更新 package.json 中所有 Nestjs 依赖项的版本后,无法使用 npm install - Can't use npm install after I updated the version of all nestjs dependencies in my package.json NPM不会安装所有依赖项 - NPM does not install every dependencies “ npm install”不会安装所有依赖 - “npm install” doesn't installs all depencies npm install --global(对于 package.json 的所有依赖项) - npm install --global (for all dependencies on package.json)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM