question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Github Javascript Action requiring ESLint throws `Cannot find module '@eslint/eslintrc/universal'`

See original GitHub issue

Relates to third party integrations with ESLint utilizing nodejs linter API.

Tell us about your environment

  • ESLint Version: 8.0.0-beta.0
  • Node Version: 14.17.5
  • npm Version: Not sure, but it’s the one provided by Github CI
  • Operating System: Ubuntu / Github CI. Locally Debian 10.

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

Unrelevant, but default.

Please show your full configuration:

Unrelevant, but:

Configuration
{ root: true }

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Requiring eslint with absolute path fails due to @eslint/eslintrc/universal being unable to load.

https://github.com/eslint/eslint/blob/c9947d2a3e0250928d4d80f3b287f10e68fc8db2/lib/linter/linter.js#L27

I’m only able to reproduce this issue in Github CI. In local environment it always works. I have no idea why.

const pkgPath = path.resolve('./node_modules/eslint');
console.log(`Running require('${pkgPath}')`);
require(pkgPath);
Running require('/home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint')
Cannot find module '@eslint/eslintrc/universal'
Require stack:
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/linter/linter.js
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/linter/index.js
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/cli-engine/cli-engine.js
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/eslint/eslint.js
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/eslint/index.js
- /home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/lib/api.js
- /home/runner/work/_actions/AriPerkkio/eslint-remote-tester-run-action/test/eslint-v8/dist/index.js

https://github.com/AriPerkkio/eslint-remote-tester-bot-test-setups/runs/3449285821?check_suite_focus=true

This error message is also mentioned in different issue: https://github.com/eslint/eslint/issues/14936#issuecomment-905786726.

What did you expect to happen?

Should work exactly as v7 works. This issue only comes up with v8 beta. Eslint@7 works fine.

What actually happened? Please copy-paste the actual, raw output from ESLint.

eslint/lib/linter/linter.js fails to load.

Steps to reproduce this issue:

Sorry for not being able to provide easy repro but I’ll try to describe the situtation.

Run this file in Github CI https://github.com/AriPerkkio/eslint-remote-tester-run-action/blob/acb6f063cb0d9ea8dfd183e69caba14dd7a67330/dist/index.js.

In minimal repro: eslint-remote-tester-run-acton imports eslint using absolute path. This is how Github CI Action can utilize dependencies of projects it is being used in. https://github.com/AriPerkkio/eslint-remote-tester-run-action/blob/acb6f063cb0d9ea8dfd183e69caba14dd7a67330/dist/index.js#L24-L27

In my real use case:

  1. Npm package eslint-remote-tester utilizes ESLint’s Nodejs API: engine/worker-task.ts
  2. Github CI action eslint-remote-tester-run-action is requring eslint-remote-tester using absolute path: peer-dependencies.ts.
  3. Dependency chain: eslint-remote-tester-run-action -> eslint-remote-tester -> eslint -> @eslint/eslintrc/universal

Are you willing to submit a pull request to fix this bug?

Yes.

Some debugging narrowing common mistakes out of scope

https://github.com/AriPerkkio/eslint-remote-tester-bot-test-setups/runs/3449285821?check_suite_focus=true

  1. ./node_modules/@eslint/eslintrc/dist and its universal is available on file system ✅
> ls ./node_modules/@eslint/eslintrc/dist

eslintrc-universal.cjs
eslintrc-universal.cjs.map
eslintrc.cjs
eslintrc.cjs.map 
  1. eslint@8 is available on file system ✅
Running require('/home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/eslint/package.json')
{
  name: 'eslint',
  version: '8.0.0-beta.0',
  ...
  1. @eslint/eslintrc@1 is available on file system ✅
Running require('/home/runner/work/eslint-remote-tester-bot-test-setups/eslint-remote-tester-bot-test-setups/node_modules/@eslint/eslintrc/package.json')
{
  name: '@eslint/eslintrc',
  version: '1.0.0',
  description: 'The legacy ESLintRC config file format for ESLint',
  type: 'module',
  main: './dist/eslintrc.cjs',
  exports: {
    '.': { import: './lib/index.js', require: './dist/eslintrc.cjs' },
    './package.json': './package.json',
    './universal': {
      import: './lib/index-universal.js',
      require: './dist/eslintrc-universal.cjs'
    }
...

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Aug 30, 2021

Right, I’m saying that my action only has one version of node available for anything 😃

1reaction
ljharbcommented, Aug 29, 2021

setup-node doesn’t have node > 12 yet, but https://github.com/ljharb/actions works fine :-p

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module 'eslint' · Issue #54 - GitHub
In my case I have multiple projects using eslint in different directories and I need a way to specify their locations. I wish...
Read more >
Feature request: Support snapshot testing #14936 - GitHub
... Test suite failed to run Cannot find module '@eslint/eslintrc/universal' from 'node_modules/eslint/lib/linter/linter.js' Require stack: ...
Read more >
"Cannot find module 'eslint-plugin-react'" when trying to run ...
Below error appears event when trying to run what I pressume should be a version command (standard -v or standard -V) What operating...
Read more >
Error: Cannot find module 'eslint-plugin-react' · Issue #3782
pawelgrzybek$ eslint js/script1.js module.js:338 throw err; ... I got the error Cannot find module 'eslint-plugin-react' and npm install -g ...
Read more >
With 2.0.0-x Error: Cannot find module 'eslint-config-eslint'
Linting foo.js with .eslintrc.yml containing extends: "eslint". eslint and eslint-config-eslint are installed globally. With rc.0 and beta.3 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found