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

πŸ› 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": "yarn@3.6.0",
  "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://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)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 12
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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

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 πŸ™‚

I’m having the same issue. simply running

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

triggers the problem.

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.

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

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.

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

[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.

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. πŸ˜‰ πŸ™ˆ)