Github Javascript Action requiring ESLint throws `Cannot find module '@eslint/eslintrc/universal'`
See original GitHub issueRelates 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.
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
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:
- Npm package
eslint-remote-tester
utilizes ESLint’s Nodejs API: engine/worker-task.ts - Github CI action
eslint-remote-tester-run-action
is requringeslint-remote-tester
using absolute path: peer-dependencies.ts. - 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
./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
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',
...
@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:
- Created 2 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
Right, I’m saying that my action only has one version of node available for anything 😃
setup-node doesn’t have node > 12 yet, but https://github.com/ljharb/actions works fine :-p