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

Yarn 2: Error: Failed to load config "xo/esnext" to extend from. #418

Closed
jonahsnider opened this issue Jan 26, 2020 · 8 comments
Closed

Comments

@jonahsnider
Copy link
Contributor

I am upgrading to Yarn 2 and I am now getting the following error

Error: Failed to load config "xo/esnext" to extend from.
Referenced from: BaseConfig
    at configMissingError (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array-factory.js:265:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array
-factory.js:826:23)
    at ConfigArrayFactory._loadExtends (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array-factory.js:731:
25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-arr
ay-factory.js:660:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array-f
actory.js:596:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at createConfigArray (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array-factory.js:340:25)
    at ConfigArrayFactory.create (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/config-array-factory.js:395:16)
    at createBaseConfigArray (/project/.yarn/cache/eslint-npm-6.8.0-d27045f313-1.zip/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:86:4
8)

I am only extending xo-typescript in my XO config and this error only started occurring after using Yarn 2.
I believe the error is due to Yarn 2's "strict package boundaries".

Packages aren't allowed to require other packages unless they actually list them in their dependencies. This is in line with the changes we made back when we introduced Plug'n'Play more than a year ago, and we're happy to say that the work we've been doing with the top maintainers of the ecosystem have been fruitful. Nowadays, very few packages still have compatibility issues with this rule. source
Whatever is requiring xo/esnext doesn't have it listed in their dependencies and is failing.

@sindresorhus
Copy link
Member

I would recommend opening an issue on the Yarn 2 repo about this incompatibility. I’m sure it affects ESLint too. I don’t use Yarn, so I’m not going to spend any time looking into this, unfortunately.

@friederbluemle
Copy link

I'm getting the same exact error when installing with Yarn 1.22.4 (yarn global add xo).
The issue seems to be related with the global installation: #404

@deep5050
Copy link

with npm 6.13.7 too :(

@niftylettuce
Copy link

Using yarn v1.x and same issue:

~/Projects/graceful master* 19s
❯ yarn test
yarn run v1.22.4
$ npm run lint && npm run test-coverage
npm WARN lifecycle The node binary used for scripts is /var/folders/t_/4vd3m1h92zsc953ll8r_4s_h0000gn/T/yarn--1594219180323-0.28126307126174055/node but npm is using /Users/someuser/.nvm/versions/node/v12.18.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> @ladjs/[email protected] lint /Users/someuser/Projects/graceful
> xo && remark . -qfo

Error: Cannot find module 'lodash/fp'
Require stack:
- /Users/someuser/Projects/graceful/node_modules/enhance-visitors/index.js
- /Users/someuser/Projects/graceful/node_modules/eslint-plugin-ava/rules/assertion-arguments.js
- /Users/someuser/Projects/graceful/node_modules/import-modules/index.js
- /Users/someuser/Projects/graceful/node_modules/eslint-plugin-ava/index.js
- /Users/someuser/Projects/graceful/node_modules/eslint/lib/config/plugins.js
- /Users/someuser/Projects/graceful/node_modules/eslint/lib/config.js
- /Users/someuser/Projects/graceful/node_modules/eslint/lib/cli-engine.js
- /Users/someuser/Projects/graceful/node_modules/eslint/lib/api.js
- /Users/someuser/Projects/graceful/node_modules/xo/index.js
- /Users/someuser/Projects/graceful/node_modules/xo/cli-main.js
- /Users/someuser/Projects/graceful/node_modules/xo/cli.js
Referenced from:
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/someuser/Projects/graceful/node_modules/enhance-visitors/index.js:3:11)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ladjs/[email protected] lint: `xo && remark . -qfo`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ladjs/[email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/someuser/.npm/_logs/2020-07-08T14_39_41_648Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

~/Projects/graceful master*
❯ yarn --version

@markerdmann
Copy link

markerdmann commented Oct 29, 2020

@sindresorhus Same error with npm v6.14.8

@andersk
Copy link
Contributor

andersk commented Nov 8, 2020

A workaround for Yarn 2 is to add all the relevant ESLint config packages and plugins as direct devDependencies of your project, e.g.

yarn add -D eslint eslint-config-xo eslint-plugin-{ava,eslint-comments,import,no-use-extend-native,node,promise,unicorn}

Probably relevant: yarnpkg/berry#8, eslint/eslint#3458.

@andersk
Copy link
Contributor

andersk commented Nov 9, 2020

That workaround fails, though, with enableGlobalCache: true in .yarnrc.yml. (This particular bug might be yarnpkg/berry#706.)

$ yarn run xo
Error: Cannot read config file: /home/anders/.yarn/berry/cache/xo-npm-0.34.2-8d37d87fc6-7.zip/node_modules/xo/config/plugins.js
Error: Cannot find module '/home/anders/.yarn/berry/cache/xo-npm-0.34.2-8d37d87fc6-7.zip/node_modules/xo/config/plugins.js'
Require stack:
- /home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/noop.js
Require stack:
- /home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/noop.js
Referenced from: BaseConfig
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.external_module_.Module._resolveFilename (/tmp/z/.pnp.js:11698:54)
    at resolveFileName (/home/anders/.yarn/berry/cache/resolve-from-npm-4.0.0-f758ec21bf-7.zip/node_modules/resolve-from/index.js:29:39)
    at resolveFrom (/home/anders/.yarn/berry/cache/resolve-from-npm-4.0.0-f758ec21bf-7.zip/node_modules/resolve-from/index.js:43:9)
    at module.exports (/home/anders/.yarn/berry/cache/resolve-from-npm-4.0.0-f758ec21bf-7.zip/node_modules/resolve-from/index.js:46:41)
    at module.exports (/home/anders/.yarn/berry/cache/import-fresh-npm-3.2.2-509b4e1291-7.zip/node_modules/import-fresh/index.js:14:19)
    at loadJSConfigFile (/home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/config-array-factory.js:225:16)
    at loadConfigFile (/home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/config-array-factory.js:308:20)
    at ConfigArrayFactory._loadConfigData (/home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/config-array-factory.js:608:42)
    at ConfigArrayFactory._loadExtendedShareableConfig (/home/anders/.yarn/berry/cache/@eslint-eslintrc-npm-0.2.1-88318143fb-7.zip/node_modules/@eslint/eslintrc/lib/config-array-factory.js:883:21)

@floer32
Copy link

floer32 commented Dec 15, 2020

weirdly, i only have this issue inside of JetBrains IDEs. (I haven't tested everywhere.) I've tried various ways of installing and picking which bin to use (local vs global, different versions, etc). And consistently, it works in the terminal but not in my IDE.

So I'm guessing there's something dependent on shell or env var shenanigans. (At least, if also using fnm or other things like that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants