'The dependency (non-development) of other dependency has not been automatically added to node_modules
I has been told
ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".
(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "D:\XXX\NNN".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install @typescript-eslint/eslint-plugin@latest --save-dev
by ESLint. Why it's strange is the package with ESLint preset has @typescript-eslint/eslint-plugin among dependencies:
{
"name": "@yamato_daiwa/style_guides",
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.19.0",
"@typescript-eslint/parser": "5.19.0",
"eslint": "8.13.0",
"eslint-plugin-node": "11.1.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.13.0",
"eslint-plugin-node": "^11.1.0",
"typescript": ">=4.0.0 <4.7.0"
}
}
(I am not sure that peerDependencies are required but I must keep this question focues on one problem)
I expected that all dependencies will be automatically added to node_modules but it has not been (there is no @typescript-eslint
among scope directories):
My node version is 16.3.
Update
Looks like @typescript-eslint/eslint-plugin
has been added to node_modules
below library with ESLint preset. I expected it will be added to directory below node_modules
of the project, not below project/node_modules/@yamato-daiwa/style_guides/node_modules
.
Solution 1:[1]
Do you really need eslint-plugin as a peerDependency in your project? If so, inspect that you're trying to install the same version of eslint-plugin as the lib that is requiring it. If not, remove it.
according to documentation: "When a dependency is listed in a package as a peerDependency, it is not automatically installed. Instead, the code that includes the package must include it as its dependency. npm will warn you if you run npm install and it does not find this dependency."
https://flaviocopes.com/npm-peer-dependencies/
If all else fails, try running "npm ci" (clean install) rather than npm install.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |