import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.55k stars 1.57k forks source link

CI WSL Error: Cannot find module 'semver' #2737

Open AndyOGo opened 1 year ago

AndyOGo commented 1 year ago

All jobs with WSL config fail on master. https://ci.appveyor.com/project/ljharb/eslint-plugin-import/builds/46338908

E.g.: https://ci.appveyor.com/project/ljharb/eslint-plugin-import/builds/46338908/job/hqyre5h5sbfqqn44

Error: Cannot find module 'semver'
Require stack:
- /mnt/c/projects/eslint-plugin-import/tests/src/cli.js
- /mnt/c/projects/eslint-plugin-import/node_modules/mocha/lib/mocha.js
- /mnt/c/projects/eslint-plugin-import/node_modules/mocha/index.js
- /mnt/c/projects/eslint-plugin-import/node_modules/mocha/bin/_mocha
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
    at Function.Module._load (node:internal/modules/cjs/loader:866:27)
    at Module.require (node:internal/modules/cjs/loader:1093:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at Object.<anonymous> (/mnt/c/projects/eslint-plugin-import/tests/src/cli.js:9:1)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Module.replacementCompile (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at loader (/mnt/c/projects/eslint-plugin-import/node_modules/babel-register/lib/node.js:144:5)
    at require.extensions.<computed> (/mnt/c/projects/eslint-plugin-import/node_modules/babel-register/lib/node.js:154:7)
    at Object.<anonymous> (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Module.require (node:internal/modules/cjs/loader:1093:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at /mnt/c/projects/eslint-plugin-import/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/mnt/c/projects/eslint-plugin-import/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/mnt/c/projects/eslint-plugin-import/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/mnt/c/projects/eslint-plugin-import/node_modules/mocha/bin/_mocha:480:18)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Module.replacementCompile (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
    at /mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/append-transform/index.js:62:4
    at require.extensions.<computed> (/mnt/c/projects/eslint-plugin-import/node_modules/babel-register/lib/node.js:152:7)
    at Object.<anonymous> (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at runMain (/home/appveyor/.node-spawn-wrap-41-9e09463faa5b/node:68:10)
    at Function.<anonymous> (/home/appveyor/.node-spawn-wrap-41-9e09463faa5b/node:171:5)
    at Object.<anonymous> (/mnt/c/projects/eslint-plugin-import/node_modules/nyc/bin/wrap.js:23:4)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at /home/appveyor/.node-spawn-wrap-41-9e09463faa5b/node:178:8
    at Object.<anonymous> (/home/appveyor/.node-spawn-wrap-41-9e09463faa5b/node:181:3)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/mnt/c/projects/eslint-plugin-import/tests/src/cli.js',
    '/mnt/c/projects/eslint-plugin-import/node_modules/mocha/lib/mocha.js',
    '/mnt/c/projects/eslint-plugin-import/node_modules/mocha/index.js',
    '/mnt/c/projects/eslint-plugin-import/node_modules/mocha/bin/_mocha'
  ]
}
ljharb commented 1 year ago

I'm aware of this, but I'm not sure what's causing it. I'd love a PR that can fix it (or alternatively, migrate windows tests to GHA).

AndyOGo commented 1 year ago

mocha seems to make use of it πŸ€”

I found an issue over there from 2019, which is closed https://github.com/mochajs/mocha/issues/3868

That fix landed in v6.1.2. https://github.com/mochajs/mocha/blob/283db20b3c203d3cb3b91919b1e36fbb7d764153/package.json#L3

Latest is 10.2.0

But mocha is far behind here.

npm ls mocha
eslint-plugin-import@2.27.5 /eslint-plugin-import
β”œβ”€β”¬ eslint-import-resolver-node@0.3.7 -> ./resolvers/node
β”‚ └── mocha@3.5.3 deduped
β”œβ”€β”¬ eslint-import-resolver-webpack@0.13.2 -> ./resolvers/webpack
β”‚ └── mocha@3.5.3 deduped
└── mocha@3.5.3

Anyway semver doesn't seem to be listed as a dependency of mocha πŸ˜•

npm list semver
eslint-plugin-import@2.27.5 /eslint-plugin-import
β”œβ”€β”¬ @typescript-eslint/parser@5.55.0
β”‚ └─┬ @typescript-eslint/typescript-estree@5.55.0
β”‚   └── semver@7.3.8
β”œβ”€β”¬ babel-plugin-istanbul@4.1.6
β”‚ β”œβ”€β”¬ istanbul-lib-instrument@1.10.2
β”‚ β”‚ └── semver@5.7.1
β”‚ └─┬ test-exclude@4.2.3
β”‚   └─┬ read-pkg-up@1.0.1
β”‚     └─┬ read-pkg@1.1.0
β”‚       └─┬ normalize-package-data@2.5.0
β”‚         └── semver@5.7.1
β”œβ”€β”¬ babel-preset-airbnb@2.6.0
β”‚ └─┬ babel-preset-env@1.7.0
β”‚   └── semver@5.7.1
β”œβ”€β”¬ eslint-doc-generator@1.4.3
β”‚ └─┬ @typescript-eslint/utils@5.55.0
β”‚   └── semver@7.3.8
β”œβ”€β”¬ eslint-import-resolver-webpack@0.13.2 -> ./resolvers/webpack
β”‚ └── semver@5.7.1
β”œβ”€β”¬ eslint-plugin-import@2.27.5
β”‚ └── semver@6.3.0 deduped
β”œβ”€β”¬ nyc@11.9.0
β”‚ β”œβ”€β”¬ istanbul-lib-instrument@1.10.1
β”‚ β”‚ └── semver@5.5.0
β”‚ └─┬ test-exclude@4.2.1
β”‚   └─┬ read-pkg-up@1.0.1
β”‚     └─┬ read-pkg@1.1.0
β”‚       └─┬ normalize-package-data@2.4.0
β”‚         └── semver@5.5.0 deduped
β”œβ”€β”¬ safe-publish-latest@2.0.0
β”‚ └── semver@7.3.8
β”œβ”€β”€ semver@6.3.0
└─┬ typescript-eslint-parser@22.0.0
  └─┬ typescript-estree@18.0.0
    └── semver@5.5.0
AndyOGo commented 1 year ago

I cloned mocha and checked out the v3.5.3 tag

npm list -prod semver
mocha@3.5.3 /mocha
└── (empty)
npm list -dev semver
mocha@3.5.3 /mocha
β”œβ”€β”¬ karma@1.3.0
β”‚ └─┬ log4js@0.6.38
β”‚   └── semver@4.3.6
β”œβ”€β”¬ nyc@11.9.0
β”‚ β”œβ”€β”¬ istanbul-lib-instrument@1.10.1
β”‚ β”‚ └── semver@5.5.0
β”‚ └─┬ test-exclude@4.2.1
β”‚   └─┬ read-pkg-up@1.0.1
β”‚     └─┬ read-pkg@1.1.0
β”‚       └─┬ normalize-package-data@2.4.0
β”‚         └── semver@5.5.0 deduped
β”œβ”€β”¬ os-name@2.0.1
β”‚ └─┬ win-release@1.1.1
β”‚   └── semver@5.7.1
└─┬ phantomjs@1.9.8
  └─┬ npmconf@0.0.24
    └── semver@1.1.4
ljharb commented 1 year ago

Yes, we're stuck on mocha v3. Does that depend on node-environment-flags? Maybe a workaround is to manually install a fixed version of it.

AndyOGo commented 1 year ago

I missed the obvious.

semver is installed and utilized by no-duplicates: https://github.com/import-js/eslint-plugin-import/blob/5680a1f8d41cd19f9c60d999a6fadf10994a0a64/src/rules/no-duplicates.js#L3

ljharb commented 1 year ago

Good call, and it's in the project's dependencies, so there's no reason it shouldn't be present.

AndyOGo commented 1 year ago

Indeed.

I googled that error. These sources suggest that npm is mesed up somehow and to re-install it. I can only guess. Do you have access to try that?

ljharb commented 1 year ago

All of that is handled in appveyor.yml - PRs are quite welcome :-)

AndyOGo commented 1 year ago

I created just a workaround and excluded the remaining WSL jobs.

A proper solution is still required.

ljharb commented 1 year ago

I prefer to leave them failing rather than skip them.

AndyOGo commented 1 year ago

I understand. It is what is and has a bitter taste. I closed them.

AndyOGo commented 1 year ago

@ljharb I tried to install it via nvm as suggested here, but that failed miserably. https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl#install-nvm-nodejs-and-npm

AndyOGo commented 1 year ago

https://help.appveyor.com/discussions/problems/34173-cant-test-nodejs-on-wsl