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]A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't #587

Closed
lzm0x219 opened this issue Nov 18, 2019 · 14 comments
Labels
bug Something isn't working

Comments

@lzm0x219
Copy link

Failed to load parser '@typescript-eslint/parser' declared in 'BaseConfig » /Users/vvni/OffSource/yunmeng-mall-webapp/.yarn/virtual/eslint-config-react-app-virtual-fa3c1f4ab2/0/cache/eslint-config-react-app-npm-5.0.2-b7b16e6537-1.zip/node_modules/eslint-config-react-app/index.js#overrides[0]': A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't

Required package: typescript (via "typescript")
Required by: @typescript-eslint/typescript-estree@virtual:44860fa3e51ac3b5ff8d790a8c36fb7d6ab296a0c395a0e1c3db2cc1dcc9433416e53144c77819fccdd3d8ce8abba0ee2d1c2f0c6a00888059b912e0edde4e26#npm:2.7.0 (via /Users/vvni/OffSource/yunmeng-mall-webapp/.yarn/virtual/@typescript-eslint-typescript-estree-virtual-dd21f9bbc0/0/cache/@typescript-eslint-typescript-estree-npm-2.7.0-1b6868dd7c-1.zip/node_modules/@typescript-eslint/typescript-estree/dist/parser.js)

@lzm0x219 lzm0x219 added the bug Something isn't working label Nov 18, 2019
@lzm0x219
Copy link
Author

image

@arcanis
Copy link
Member

arcanis commented Nov 18, 2019

  1. No reproduction case makes it hard to be sure
  2. Do you have a peer dependency warning when running yarn install?

My best guess is that both of those packages should list typescript as an (optional) peer dependency, since typescript-estree requires to access it:

https://cdn.jsdelivr.net/npm/@typescript-eslint/parser/package.json
https://cdn.jsdelivr.net/npm/eslint-config-react-app/package.json

@lzm0x219
Copy link
Author

lzm0x219 commented Nov 18, 2019 via email

@viceice
Copy link

viceice commented Jan 9, 2020

As this is closed, is there any solution for this?

Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.js » eslint-config-airbnb-typescript/base » ~\projects\gh\renovate\.yarn\$$virtual\eslint-config-airbnb-typescript-virtual-b3c2d2fd87\0\cache\eslint-config-airbnb-typescript-npm-6.3.1-4f1c427688-1.zip\node_modules\eslint-config-airbnb-typescript\lib\shared.js': A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't

Required package: typescript (via "typescript")
Required by: @typescript-eslint/typescript-estree@virtual:fc78876e07396419642eda8c10ed454eda15b9e947b012c4f00d3f606e7cb49afb907a2ed72c020045a13197ba1eae0805cfae2b9a4b2752b3c0e15634a954c5#npm:2.14.0 (via /C:/Users/kriese/projects/gh/renovate/.yarn/$$virtual/@typescript-eslint-typescript-estree-virtual-0393465a19/0/cache/@typescript-eslint-typescript-estree-npm-2.14.0-0548142d0a-1.zip/node_modules/@typescript-eslint/typescript-estree/dist/)

Require stack:
- ~\projects\gh\renovate\.yarn\$$virtual\@typescript-eslint-typescript-estree-virtual-0393465a19\0\cache\@typescript-eslint-typescript-estree-npm-2.14.0-0548142d0a-1.zip\node_modules\@typescript-eslint\typescript-estree\dist\parser.js
- ~\projects\gh\renovate\.yarn\$$virtual\@typescript-eslint-parser-virtual-fc78876e07\0\cache\@typescript-eslint-parser-npm-2.14.0-766de38fdd-1.zip\node_modules\@typescript-eslint\parser\dist\parser.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\config-array-factory.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\cli-engine.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli-engine\index.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\lib\cli.js
- ~\projects\gh\renovate\.yarn\cache\eslint-npm-6.8.0-d27045f313-1.zip\node_modules\eslint\bin\eslint.js
    at Object.makeError (~\projects\gh\renovate\.pnp.js:20146:24)
    at resolveToUnqualified (~\projects\gh\renovate\.pnp.js:24561:35)
    at resolveRequest (~\projects\gh\renovate\.pnp.js:24654:27)
    at Object.resolveRequest (~\projects\gh\renovate\.pnp.js:24722:26)
    at Function.module_1.Module._resolveFilename (~\projects\gh\renovate\.pnp.js:23960:34)
    at Function.module_1.Module._load (~\projects\gh\renovate\.pnp.js:23835:40)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (~\projects\gh\renovate\.yarn\cache\v8-compile-cache-npm-2.1.0-86ea69cdd0-1.zip\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
    at Object.<anonymous> (~\projects\gh\renovate\.yarn\$$virtual\@typescript-eslint-typescript-estree-virtual-0393465a19\0\cache\@typescript-eslint-typescript-estree-npm-2.14.0-0548142d0a-1.zip\node_modules\@typescript-eslint\typescript-estree\dist\parser.js:17:25)
    at Module._compile (~\projects\gh\renovate\.yarn\cache\v8-compile-cache-npm-2.1.0-86ea69cdd0-1.zip\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)

https://github.com/ViceIce/renovate/tree/feat/yarn-pnp

@arcanis
Copy link
Member

arcanis commented Jan 9, 2020

@viceice in your case this is because eslint-config-airbnb-typescript doesn't list typescript in its peer dependencies, so its dependencies (including @typescript-eslint/parser) don't have permission to access it.

TypeScript being missing isn't displayed here because @typescript-eslint/parser only list it as an optional peer dependency, but it's the same error as the others printed here:

image

@viceice
Copy link

viceice commented Jan 9, 2020

if i add the following to my .yarnrc.yml eslint crashes with oom

packageExtensions:
  "eslint-config-airbnb-typescript@*":
    peerDependencies:
      eslint: "*"
      eslint-plugin-import: "*"
      typescript: "*"

@viceice
Copy link

viceice commented Jan 9, 2020

yarn: 2.0.0-rc.21
node: v12.14.0

<--- Last few GCs --->

[3916:000002331CB60C80]   415470 ms: Mark-sweep 2039.4 (2050.9) -> 2038.5 (2050.9) MB, 2585.7 / 0.0 ms  (average mu = 0.108, current mu = 0.018) allocation failure scavenge might not succeed[3916:000002331CB60C80]   418878 ms: Mark-sweep 2039.5 (2050.9) -> 2038.7 (2050.9) MB, 3383.9 / 0.1 ms  (average mu = 0.061, current mu = 0.007) allocation failure scavenge might not succeed


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 00007FF6FB0F404D]
Security context: 0x00666f6008a1 <JSObject>
    1: split [000000666F60D031](this=0x0030fb45e2f1 <String[66]: ~/projects/gh/renovate/test/manager/mix/extract.spec.ts>,0x02fadfd93699 <String[#1]: />)
    2: pathComponents(aka pathComponents) [000000810570D081] [~\projects\gh\renovate\.yarn\cache\typescript-patch-d665bedbda-1.zip\node_modules\typescript\lib\typescript.js:~5972]...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF6FA52124F napi_wrap+124431
 2: 00007FF6FA4C2A06 v8::base::CPU::has_sse+34502
 3: 00007FF6FA4C36C6 v8::base::CPU::has_sse+37766
 4: 00007FF6FACC82DE v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF6FACB0321 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF6FAB7DBEC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF6FAB88F90 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312
 8: 00007FF6FAB85AC4 v8::internal::Heap::PageFlagsAreConsistent+3204
 9: 00007FF6FAB7B353 v8::internal::Heap::CollectGarbage+1283
10: 00007FF6FAB79B24 v8::internal::Heap::AddRetainedMap+2356
11: 00007FF6FABA19B3 v8::internal::Factory::NewRawOneByteString+83
12: 00007FF6FABA11BB v8::internal::Factory::NewProperSubString+891
13: 00007FF6FA8E33A1 v8::internal::DeclarationScope::was_lazily_parsed+32225
14: 00007FF6FB0F404D v8::internal::SetupIsolateDelegate::SetupHeap+567949
15: 00007FF6FB0E17AA v8::internal::SetupIsolateDelegate::SetupHeap+492010
16: 0000038CEB9AE814

@Mellbourn
Copy link

Mellbourn commented Feb 7, 2020

I get the same error message but with much less information about what is actually missing:

Failed to compile
./.yarn/$$virtual/apollo-utilities-virtual-7a551de862/0/cache/apollo-utilities-npm-1.3.3-8e73ac22c0-1.zip/node_modules/apollo-utilities/lib/bundle.esm.js
Module not found: A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't
This error occurred during the build time and cannot be dismissed.

So, I have no idea how to work around this.

This is my project:
https://github.com/Mellbourn/saved-counter/tree/yarn2
@arcanis Doing yarn start in the subfolder packages/client should reproduce the problem.

@JosNun
Copy link

JosNun commented Feb 16, 2020

Same. @Mellbourn Did you ever find a solution to this?

Fwiw, my issue is occurring with styled-components.

@Mellbourn
Copy link

@JosNun nope. Gave up on berry for now

@danbalarin
Copy link

@JosNun I've had similar issues with many packages (I have circa 40 entries in .yarnrc.yaml file). I got stuck on apollo-client just as @Mellbourn and manage to solve it by unplugging desired package (apollo-utilities in my case) and manually move peerDependency (graphql in my case) to the dependencies and run yarn.
Please be aware that this might cause some unexpected issues and this change will be rolled back with package update. In the end, I'm able to run apollo-client with yarn@berry but this is now even proper workaround, just some hot fix, that should be removed ASAP.

@darioblanco
Copy link

I know this might be silly but... Have you @Vvni and @viceice explicitly defined the typescript package, let's say, in your package.json devDependencies part?

I stumbled upon the same issue and I just figured out I totally forgot to do a yarn add -D typescript. That fixed my issue.

@hex22a
Copy link

hex22a commented Mar 29, 2020

@darioblanco i have typescript listed in my dependencies but still getting "Failed to load parser" error 🤷‍♂️

@bertho-zero
Copy link

Should works with

# .yarnrc.yml

pnpMode: "loose"
pnpFallbackMode: "all"

or

# .yarnrc.yml

nodeLinker: "node-modules"

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

9 participants