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
- Fix Parcel failing in Yarn PnP mode (and peer dependency warning) Fixes #9114 — committed to wojtekmaj/parcel by wojtekmaj 9 months ago
- No luck. Parcel build fails :( https://github.com/parcel-bundler/parcel/issues/9114 — committed to signature-opensource/CK-Observable-Domain by olivier-spinelli 9 months ago
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)
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
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.ymlFor projects with multiple workspaces, this applies the extensions to all of them.
You might need to add
@parcel/coreto@parcel/typesas well, if you use that, as Iβm getting a warning here as well: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:
Save file and run
yarn installa few times Try building againMy package.js devDependencies looks like this now (ignore the packager-raw-url, transformer-webmanifest):
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. π π)