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.

[Bug?]: ESLint extension doesn't work with yarn pnp - Error: Missing "./lib/api.js" export in "eslint" package

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

I’m using the ESLint extension in VSCode. Unfortunately it doesn’t work with Plug’n’Play - according to the docs it should work if I understand correctly?

I’ve been looking at issues both here and in the ESLint extension repro but I haven’t found anyone with this exact error it seems. I’m not sure if the issue belongs here or in the ESLint extension repro, let me know.

To reproduce

Make sure you have arcanis.vscode-zipfs and dbaeumer.vscode-eslint extensions installed in VS Code.

Run the following commands and just select defaults in the config initialization wizard

mkdir eslint-test
cd eslint-test
yarn set version berry
yarn init
yarn add -D eslint
yarn dlx @yarnpkg/sdks vscode
yarn eslint --init

Now verify that eslint will highlight an error in .eslintrc.js when running the following command (as expected)

yarn eslint .

Open eslintrc.js in VS Code and verify that the ESLint extension doesn’t work. You can select the Output tab and select ESLint in the dropdown and see the following error

[Error - 2:16:22 PM] Error: Missing "./lib/api.js" export in "eslint" package
Require stack:
- /home/nixd/Projects/eslint-test/.pnp.cjs
    at bail (/home/nixd/Projects/eslint-test/.pnp.cjs:10700:8)
    at resolve (/home/nixd/Projects/eslint-test/.pnp.cjs:10776:10)
    at applyNodeExportsResolution (/home/nixd/Projects/eslint-test/.pnp.cjs:11027:28)
    at resolveUnqualifiedExport (/home/nixd/Projects/eslint-test/.pnp.cjs:11540:35)
    at resolveRequest (/home/nixd/Projects/eslint-test/.pnp.cjs:11606:99)
    at Object.resolveRequest (/home/nixd/Projects/eslint-test/.pnp.cjs:11681:26)
    at Function.external_module_.Module._resolveFilename (/home/nixd/Projects/eslint-test/.pnp.cjs:10533:34)
    at Function.external_module_.Module._load (/home/nixd/Projects/eslint-test/.pnp.cjs:10355:48)
    at Module.require (internal/modules/cjs/loader.js:1006:19)
    at require (internal/modules/cjs/helpers.js:88:18)
[Error - 2:20:20 PM] Error: Missing "./lib/api.js" export in "eslint" package

Environment

System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Binaries:
    Node: 15.14.0 - /tmp/xfs-affdb263/node
    Yarn: 3.0.2 - /tmp/xfs-affdb263/yarn
    npm: 7.24.1 - ~/.nvm/versions/node/v15.14.0/bin/npm

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
merceyzcommented, Nov 10, 2021

This was fixed in https://github.com/yarnpkg/berry/pull/3709 but we forgot to reference this issue

yarn dlx @yarnpkg/sdks
4reactions
joelmukuthucommented, Oct 15, 2021

Hi @mr-bjerre I just experienced the same issue. This is specifically an error with ESLint v8 and is caused by https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0#the-lib-entrypoint-has-been-removed.

Before it’s fixed here, you can workaround it by updating your ESLint SDK file (.yarn/sdks/eslint/lib/api.js). Change the export from:

// Defer to the real eslint your application uses
module.exports = absRequire(`eslint/lib/api.js`);

To:

// Defer to the real eslint your application uses
module.exports = absRequire(`eslint`);
Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint 8.0: doesn't work with YarnPnP : WEB-52594 - YouTrack
Initialization error (ESLint). Missing "./lib/options" export in "eslint" package Require stack: - /home/jetbrains/WebstormProjects/eslintYarn/package.json ...
Read more >
Yarn 3.x PNP typescript CRA eslint not working with VSCode
I ran into this issue a bit ago and found that this is due to the module resolver not pointing to the correct...
Read more >
@babel/eslint-parser | Yarn - Package Manager
ESLint parser that allows for linting of experimental syntax transformed by Babel. readme. babel. The compiler for writing next generation JavaScript.
Read more >
Yarn 2: `Error: Failed to load config "xo/esnext" to extend from.`
A workaround for Yarn 2 is to add all the relevant ESLint config packages and plugins as direct devDependencies of your project, e.g....
Read more >
Setting up a NextJS env with Yarn 2 - Dev Genius
Also, Yarn 2: ALE & ESLint not working? Yarn 2 (or yarn 3 is it? when I check the --version it ...
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