简体   繁体   English

NPM是否在node_modules下安装非根依赖关系?

[英]NPM Installing non root dependencies under node_modules?

The project @superflycss/component-navbox has the following dependencies: 项目@superflycss/component-navbox具有以下依赖项:

    "devDependencies": {
        "@superflycss/component-body": "^1.0.1",
        "@superflycss/component-display": "^1.0.2",
        "@superflycss/component-header": "^2.1.0",
        "@superflycss/component-test": "^3.6.14",
        "@superflycss/foundation": "^2.0.3",
        "@superflycss/superflycss": "^1.0.0",
        "@superflycss/utilities-colors": "^3.0.8",
        "@superflycss/utilities-effects": "^2.1.0",
        "@superflycss/utilities-fonts": "^3.3.7",
        "@superflycss/utilities-format": "^1.1.1",
        "@superflycss/utilities-layout": "^4.0.4",
        "lite-server": "^2.4.0",
        "npm-check-updates": "^2.15.0"
    },
    "dependencies": {
        "@superflycss/variables-dimension": "^2.0.0",
        "@superflycss/variables-layout": "^2.0.0"
    }

So when doing: 所以在做的时候:

git clone git@github.com:superflycss/component-navbox.git

cd component-navbox
npm i

I would expect only the root dependencies to show up in the node_modules folder. 我希望只有根依赖项才能显示在node_modules文件夹中。

However another dependency variables-colors also shows up in node_modules . 但是,另一个依赖variables-colors node_modules也显示在node_modules

IIUC this should not happen or am I missing something? IIUC这不应该发生,或者我错过了什么吗?

One of the problems with this is that the variables-colors version being installed is outdated, however since utilities-colors also depends on this, it uses the older version rather then the newer, and that leads to linting errors, etc. 问题之一是正在安装的variables-colors版本已过时,但是由于utilities-colors也依赖于此,因此它使用的是旧版本而不是更新的版本,这会导致掉毛错误等。

There was a mismatch between package-lock.json and package.json . package-lock.jsonpackage.json之间不匹配。 I removed the lock file and also node_modules and did npm i and it refreshed with all the dependencies being correct. 我删除了锁定文件,也删除了node_modules并执行了npm i ,它在所有依赖项正确的情况下刷新了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM