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] Resolve error: unable to load resolver "node" import/named with ESLint configured #1427

Closed
1 task
IT-CASADO opened this issue Jun 1, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@IT-CASADO
Copy link

  • I'd be willing to implement a fix

Describe the bug

I try to use Yarn 2 together with ESLint and Prettier, but I get this error:

Resolve error: unable to load resolver "node" import/named
Resolve error: unable to load resolver "node" import/no-extraneous-dependencies
(and five more errors)

To Reproduce

Clone this git repository: https://github.com/IT-CASADO/yarn-eslint/tree/yarn-v2
(master branch contains the same configuration with Yarn 1)

Execute following command: yarn eslint ./src/.

Environment if relevant (please complete the following information):

  • OS: [Windows]
  • Node version [12.17.0]
  • Yarn version [2.0.0-rc.33]

Additional context

I followed this steps here:

I'm assuming no configuration errors with ESLint, because it is working with Yarn 1.
Do I miss something special for Yarn 2?

@IT-CASADO IT-CASADO added the bug Something isn't working label Jun 1, 2020
@markdingram
Copy link
Contributor

Yarn 2 is stricter - see https://next.yarnpkg.com/features/pnp#pnp-loose-mode

Enabling loose mode temporarily and running outputs:

(node:34285) [MODULE_NOT_FOUND] Error: eslint-module-utils tried to access eslint-import-resolver-node, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Resolve by adding a hint to .yarnrc.yml

packageExtensions:
  eslint-module-utils@*:
    dependencies:
      eslint-import-resolver-node: "*"

@idelice
Copy link

idelice commented Aug 27, 2021

Yarn 2 is stricter - see https://next.yarnpkg.com/features/pnp#pnp-loose-mode

Enabling loose mode temporarily and running outputs:

(node:34285) [MODULE_NOT_FOUND] Error: eslint-module-utils tried to access eslint-import-resolver-node, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Resolve by adding a hint to .yarnrc.yml

packageExtensions:
  eslint-module-utils@*:
    dependencies:
      eslint-import-resolver-node: "*"

I migrated from yarn v1 to v2 and it i get the authors error on all my dependencies.

Do I have to add each one of them manually now - but also in the future?

@ljharb
Copy link

ljharb commented Aug 27, 2021

Only if you want to keep using PnP, which you can disable.

@merceyz
Copy link
Member

merceyz commented Aug 27, 2021

You can resolve the resolver manually in your eslint config to fix the resolution

module.exports = {
	settings: {
		'import/parsers': {
			[require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'],
		},
		'import/resolver': {
			[require.resolve('eslint-import-resolver-node')]: {
				extensions: [<extensions here>],
			},
		},
	},
};

@alamothe
Copy link

Resolve by adding a hint to .yarnrc.yml

packageExtensions:
  eslint-module-utils@*:
    dependencies:
      eslint-import-resolver-node: "*"

This works for executing yarn eslint, but for CRA the error still remains if I try to start the app. It makes it impossible to start. Any solution for CRA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants