Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Broken package-lock/node_modules with missing/extraneous dependency #3267

Open
1 task done
mshima opened this issue May 20, 2021 · 8 comments
Open
1 task done
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@mshima
Copy link

mshima commented May 20, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

A freshly installed package.json contains missing and extraneous dependencies.

npm ERR! code ELSPROBLEMS
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/types
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/typescript-estree
npm ERR! missing: jest-preset-angular@^8.4.0, required by @angular-builders/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @angular-eslint/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @typescript-eslint/[email protected]
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/typescript-estree/node_modules/@typescript-eslint/visitor-keys

A second npm install removes the extraneous dependencies, but don't add missing dependencies.

Expected Behavior

No response

Steps To Reproduce

  1. With this package.json:
{
  "dependencies": {
    "@angular/common": "11.2.13",
    "@angular/compiler": "11.2.13",
    "@angular/core": "11.2.13",
    "@angular/forms": "11.2.13",
    "@angular/localize": "11.2.13",
    "@angular/platform-browser": "11.2.13",
    "@angular/platform-browser-dynamic": "11.2.13",
    "@angular/router": "11.2.13",
    "@fortawesome/angular-fontawesome": "0.8.2",
    "@fortawesome/fontawesome-svg-core": "1.2.35",
    "@fortawesome/free-solid-svg-icons": "5.15.3",
    "@ng-bootstrap/ng-bootstrap": "9.1.1",
    "@ngx-translate/core": "13.0.0",
    "@ngx-translate/http-loader": "6.0.0",
    "bootstrap": "4.6.0",
    "dayjs": "1.10.4",
    "ngx-infinite-scroll": "10.0.1",
    "ngx-webstorage": "7.0.1",
    "rxjs": "6.6.7",
    "swagger-ui-dist": "3.48.0",
    "tslib": "2.2.0",
    "zone.js": "0.11.4"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "11.1.1",
    "@angular-builders/jest": "11.1.1",
    "@angular-eslint/eslint-plugin": "4.3.0",
    "@angular/cli": "11.2.12",
    "@angular/compiler-cli": "11.2.13",
    "@angular/service-worker": "11.2.13",
    "@types/jest": "26.0.23",
    "@types/node": "15.3.0",
    "@typescript-eslint/eslint-plugin": "4.24.0",
    "@typescript-eslint/parser": "4.24.0",
    "browser-sync": "2.26.14",
    "browser-sync-webpack-plugin": "2.3.0",
    "concurrently": "6.1.0",
    "copy-webpack-plugin": "6.4.1",
    "cypress": "6.6.0",
    "cypress-audit": "0.3.0",
    "eslint": "7.26.0",
    "eslint-config-prettier": "8.3.0",
    "eslint-plugin-cypress": "2.11.3",
    "eslint-webpack-plugin": "2.5.4",
    "friendly-errors-webpack-plugin": "1.7.0",
    "husky": "4.3.8",
    "jest": "26.6.3",
    "jest-date-mock": "1.0.8",
    "jest-junit": "12.0.0",
    "jest-sonar-reporter": "2.0.0",
    "lighthouse": "7.5.0",
    "lint-staged": "11.0.0",
    "merge-jsons-webpack-plugin": "1.0.21",
    "prettier": "2.3.0",
    "prettier-plugin-java": "1.0.2",
    "prettier-plugin-packagejson": "2.2.11",
    "rimraf": "3.0.2",
    "simple-progress-webpack-plugin": "2.0.0",
    "typescript": "4.1.5",
    "wait-on": "5.3.0",
    "webpack": "4.46.0",
    "webpack-bundle-analyzer": "4.4.2",
    "webpack-merge": "5.7.3",
    "webpack-notifier": "1.13.0"
  },
  "engines": {
    "node": ">=14.16.0"
  }
}
  1. Run 'npm install'
  2. Run 'npm ls --depth 10'
npm ERR! code ELSPROBLEMS
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/types
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/typescript-estree
npm ERR! missing: jest-preset-angular@^8.4.0, required by @angular-builders/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @angular-eslint/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @typescript-eslint/[email protected]
npm ERR! extraneous: @typescript-eslint/[email protected] /Users/mshima/aplicacoes/bug-tracker/node_modules/@typescript-eslint/typescript-estree/node_modules/@typescript-eslint/visitor-keys
  1. Run npm install
removed 3 packages, and audited 2284 packages in 3s
  1. Run 'npm ls --depth 10'
npm ERR! code ELSPROBLEMS
npm ERR! missing: jest-preset-angular@^8.4.0, required by @angular-builders/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @angular-eslint/[email protected]
npm ERR! missing: @typescript-eslint/[email protected], required by @typescript-eslint/[email protected]

Environment

  • OS: MacOS Big Sur (Apple Silicon)
  • Node: v14.16.1
  • npm: 7.13.0
@mshima mshima added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels May 20, 2021
@ljharb
Copy link
Contributor

ljharb commented May 20, 2021

Why are you running npm ls with a depth option at all? Due to hoisting, it’s kind of a useless argument - just run npm ls by itself.

@mshima
Copy link
Author

mshima commented May 20, 2021

Because npm ls doesn't show the problem:

$ npm ls
@
├── @angular-builders/[email protected]
├── @angular-builders/[email protected]
├── @angular-eslint/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @ng-bootstrap/[email protected]
├── @ngx-translate/[email protected]
├── @ngx-translate/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

@ljharb
Copy link
Contributor

ljharb commented May 20, 2021

That means there is no problem. The validity of your dep graph is only assessable by including the entire dep graph.

@mshima
Copy link
Author

mshima commented May 20, 2021

So the problem affects npm ls too:
See https://github.com/jhipster/generator-jhipster/runs/2625012481.

This is affecting every angular build since yesterday by this time.
https://github.com/jhipster/generator-jhipster/actions/workflows/angular.yml (succeed build were skipped).

Triggering a rebuild at succeed builds also fails.
Probably some dependency update broke the entire tree.

Error: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.json': Cannot find module '@typescript-eslint/experimental-utils'
117
Require stack:
118
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
119
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
120
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
121
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/@eslint/eslintrc/lib/config-array-factory.js
122
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/@eslint/eslintrc/lib/index.js
123
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/eslint/lib/cli-engine/cli-engine.js
124
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/eslint/lib/eslint/eslint.js
125
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/eslint/lib/eslint/index.js
126
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/eslint/lib/cli.js
127
- /home/runner/work/generator-jhipster/generator-jhipster/app/node_modules/eslint/bin/eslint.js
128
Referenced from: /home/runner/work/generator-jhipster/generator-jhipster/app/.eslintrc.json
129
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
130

@ljharb
Copy link
Contributor

ljharb commented May 20, 2021

ok - that issue (from eslint) is because @typescript-eslint/experimental-utils is missing, which it seems is perhaps the npm bug - that npm ls SHOULD be failing if it's actually missing?

@mshima
Copy link
Author

mshima commented May 20, 2021

@angular-builders/jest is missing too:
npm ERR! missing: jest-preset-angular@^8.4.0, required by @angular-builders/[email protected].

$ npm ls --depth 10
...
├─┬ @angular-builders/[email protected]
│ ├── @angular-devkit/[email protected] deduped
│ ├── @angular-devkit/[email protected] deduped
│ ├── UNMET DEPENDENCY jest-preset-angular@^8.4.0

@mshima
Copy link
Author

mshima commented May 20, 2021

Just a follow-up, adding those dependencies as direct dependencies fix the builds jhipster/generator-jhipster#15059.

@ruyadorno
Copy link
Contributor

hi @mshima is this still reproducible with the current version of the npm cli ? ([email protected] at the time of writing)

@ruyadorno ruyadorno added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants