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

@parcel/fs tried to access @parcel/core (a peer dependency) but it isn't provided by its ancestors error when following tutorial #9114

Open
perlun opened this issue Jun 27, 2023 · 18 comments

Comments

@perlun
Copy link

perlun commented Jun 27, 2023

🐛 bug report

Following the general tutorial at https://parceljs.org/getting-started/webapp/ gives me the error below when trying to run yarn parcel src/index.html.

The yarn add step worked fine and added parcel properly to the my package.json.

🎛 Configuration (.babelrc, package.json, cli command)

package.json

{
  "name": "example.com",
  "packageManager": "[email protected]",
  "devDependencies": {
    "parcel": "^2.9.3"
  }
}

I don't have any .babelrc AFAICT.

🤔 Expected Behavior

The app should be built and the devserver should be started.

😯 Current Behavior

$ yarn parcel src/index.html
Server running at http:https://localhost:1234
🚨 Build failed.

@parcel/core: Failed to resolve 'src/index.html' 
@parcel/resolver-default: @parcel/fs tried to access @parcel/core (a peer dependency) but it isn't provided by its ancestors; this makes the
 require call ambiguous and unsound.

Required package: @parcel/core
Required by: 
@parcel/fs@virtual:eef76f9fa9a588b8c892c493e6d851511aea6315c558ec074869cea35c69731f4489ed7c976fb55873d3f05e6ad5a0ad010792d1d87f51f47b52fc5dc26251b7#npm:2.9.3
 (via 
/home/per/git/example.com/.yarn/__virtual__/@parcel-fs-virtual-e623c8b450/0/cache/@parcel-fs-npm-2.9.3-f6cd93298b-c9bf9ca9e6.zip/node_modules/@parcel/fs/lib/)

Ancestor breaking the chain: @parcel/node-resolver-core@npm:3.0.3
Ancestor breaking the chain: @parcel/types@npm:2.9.3


Require stack:
- 
/home/per/git/example.com/.yarn/__virtual__/@parcel-fs-virtual-e623c8b450/0/cache/@parcel-fs-npm-2.9.3-f6cd93298b-c9bf9ca9e6.zip/node_modules/@parcel/fs/lib/index.js
- 
/home/per/git/example.com/.yarn/unplugged/@parcel-node-resolver-core-npm-3.0.3-e85849af08/node_modules/@parcel/node-resolver-core/lib/Wrapper.js
- 
/home/per/git/example.com/.yarn/unplugged/@parcel-node-resolver-core-npm-3.0.3-e85849af08/node_modules/@parcel/node-resolver-core/lib/index.js
- 
/home/per/git/example.com/.yarn/__virtual__/@parcel-package-manager-virtual-bbad0025e5/0/cache/@parcel-package-manager-npm-2.9.3-c065cee1b5-46acc905b8.zip/node_modules/@parcel/package-manager/lib/index.js
- /home/per/git/example.com/.yarn/cache/@parcel-core-npm-2.9.3-b343ad5e82-e4ba4e0909.zip/node_modules/@parcel/core/lib/resolveOptions.js
- /home/per/git/example.com/.yarn/cache/@parcel-core-npm-2.9.3-b343ad5e82-e4ba4e0909.zip/node_modules/@parcel/core/lib/Parcel.js
- /home/per/git/example.com/.yarn/cache/@parcel-core-npm-2.9.3-b343ad5e82-e4ba4e0909.zip/node_modules/@parcel/core/lib/index.js
- 
/home/per/git/example.com/.yarn/__virtual__/parcel-virtual-2add9e67f2/0/cache/parcel-npm-2.9.3-33db24662f-d9b9c0083f.zip/node_modules/parcel/lib/cli.js
- 
/home/per/git/example.com/.yarn/__virtual__/parcel-virtual-2add9e67f2/0/cache/parcel-npm-2.9.3-33db24662f-d9b9c0083f.zip/node_modules/parcel/lib/bin.js

💻 Code Sample

N/A at the moment, but can be provided if needed.

🌍 Your Environment

Software Version(s)
Parcel 2.9.3
Node v18.16.1, installed using asdf
npm/Yarn Yarn 3.6.0
Operating System Debian GNU/Linux 12 (bookworm)
@romanhrynevych
Copy link

can you give a reproduction link? https://codesandbox.io/ will be great

@Kuinox
Copy link

Kuinox commented Jun 28, 2023

I'm having the same issue.
simply running

yarn init -2
yarn add --dev parcel
yarn parcel index.html

triggers the problem.

@Kuinox
Copy link

Kuinox commented Jun 28, 2023

I made a codesanbox here: https://codesandbox.io/p/sandbox/zealous-https-z83pz3
But again, simply following the getting started using yarn lead to this. There is nothing specific.

@romanhrynevych
Copy link

please, add @parcel/core to your dev dependencies)
image

And everything will work fine: link to reproduction - https://codesandbox.io/p/sandbox/gallant-haze-t9qjqh?file=%2Fsrc%2Findex.html%3A10%2C13

Also i would recommend to add index.html to src/ folder 🙂

@Kuinox
Copy link

Kuinox commented Jun 28, 2023

Also i would recommend to add index.html to src/ folder 🙂

That's was for the demo.

please, add @parcel/core to your dev dependencies)

The getting started doesn't mention this.
image

Also, this workarounds doesn't works on bigger projects:
image

A "stable" workaround is to put yarn pnp in "loose" mode.

@romanhrynevych
Copy link

The getting started doesn't mention this.

I'm a simple dev like you, i don't have permision to edit docs 🙂

Also, this workarounds doesn't works on bigger projects:

I see that parcel in your dependencies is not similar with @parcel/ packages, maybe this is an issue)

@Kuinox
Copy link

Kuinox commented Jun 28, 2023

I see that parcel in your dependencies is not similar with @parcel/ packages, maybe this is an issue)

Ah it's just the leftover of me trying to see if it's a recent parcel change. The behavior are the same on the lastest version.

@perlun
Copy link
Author

perlun commented Jun 28, 2023

Thanks for all the feedback. 🙏 This does seem to be a real issue with following the docs with Yarn then. 🤔

(I ended up skipping Parcel for my (very simple, rudimentary) project. I detest Node.js anyway. 😉 🙈)

@romanhrynevych
Copy link

In conclusion to this, i think Parcel need to update docs to install @parcel/core in dev dependencies too)

@Kuinox
Copy link

Kuinox commented Jun 30, 2023

In conclusion to this, i think Parcel need to update docs to install @parcel/core in dev dependencies too)

As I said, it doesn't solve the issue on larger projects.

@wojtekmaj
Copy link
Contributor

FYI, Yarn's own E2Es are also broken because of this: https://github.com/yarnpkg/berry/actions/runs/5794322982/job/15703692932

@blutorange
Copy link

blutorange commented Aug 15, 2023

I agree that the proper solution is to fix the dependencies in the corresponding packages. What you can do as a workaround is to use yarn's package extension mechanism, e.g. by putting something like the following into your .yarnrc.yml

packageExtensions:
  "@parcel/node-resolver-core@*":
    dependencies:
      "@parcel/core": 2.9.3

For projects with multiple workspaces, this applies the extensions to all of them.

You might need to add @parcel/core to @parcel/types as well, if you use that, as I'm getting a warning here as well:

➤ YN0002: │ @parcel/types@npm:2.9.3 doesn't provide @parcel/core (pf46c3), requested by @parcel/fs
➤ YN0002: │ @parcel/types@npm:2.9.3 doesn't provide @parcel/core (p16f90), requested by @parcel/workers
➤ YN0002: │ @parcel/types@npm:2.9.3 doesn't provide @parcel/core (p385c8), requested by @parcel/cache
➤ YN0002: │ @parcel/types@npm:2.9.3 doesn't provide @parcel/core (p76fb9), requested by @parcel/package-manager

@olivier-spinelli
Copy link

olivier-spinelli commented Oct 11, 2023

Any progress on this? I'm stuck.
Tried the:

packageExtensions:
  "@parcel/node-resolver-core@*":
    dependencies:
      "@parcel/core": 2.9.3

No luck.

olivier-spinelli added a commit to signature-opensource/CK-Observable-Domain that referenced this issue Oct 13, 2023
@perlun
Copy link
Author

perlun commented Nov 1, 2023

@olivier-spinelli Sorry to hear that. What's the error you're seeing, the same as in my original issue description?

@olivier-spinelli
Copy link

Sorry for the delayed answer.
Yes, it's the same peer dependency error. I've been forced to switch to Vite.

@dsimonov-lionsgatewt
Copy link

dsimonov-lionsgatewt commented Jan 5, 2024

[TEMP SOLUTION] I had to create .yarnrc.yml file in the root of my project and add the following in it:

packageExtensions:
  "@parcel/node-resolver-core@*":
    dependencies:
      "@parcel/core": 2.9.3
  "@parcel/types@*":
    dependencies:
      "@parcel/core": 2.9.3
  "@parcel/fs@*":
    dependencies:
      "@parcel/core": 2.9.3

Save file and run yarn install a few times
Try building again

My package.js devDependencies looks like this now (ignore the packager-raw-url, transformer-webmanifest):

"devDependencies": {
    "@parcel/packager-raw-url": "2.11.0",
    "@parcel/transformer-webmanifest": "2.11.0",
    "parcel": "^2.11.0"
  }

Everything works now. Hope it helps someone.

@bartek-szymanski
Copy link

In my case I don't have this issue after switching to npm.

@github-actions github-actions bot added the Stale Inactive issues label Jul 25, 2024
@puresick
Copy link

Just preventing the Bot from closing this issue.
It still happens.

@github-actions github-actions bot removed the Stale Inactive issues label Jul 25, 2024
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

Successfully merging a pull request may close this issue.

9 participants