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 peer dependency issues, build fails when trying to install / start parcel dev server #7880

Closed
clarktlaugh opened this issue Mar 31, 2022 · 11 comments · Fixed by #9070
Closed

Comments

@clarktlaugh
Copy link

🐛 bug report

I am trying to install parcel using the guide at https://parceljs.org/getting-started/webapp/ and when I perform a yarn install, I get several peer dependency issues. When I run yarn parcel ./src/index.html, I get a build error:

@parcel/transformer-js: could not resolve module "@parcel/core" from ...

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

yarn version: 3.2.0
nodejs version: v16.14.2
parcel version: 2.4.0

package.json:

{
  "name": "myapp",
  "packageManager": "[email protected]",
  "source": "src/index.html",
  "scripts": {
    "start": "parcel",
    "build": "parcel build",
    "import": "node tools/import.js"
  },
  "dependencies": {
    "grommet": "^2.21.0",
    "grommet-icons": "^4.7.0",
    "grommet-theme-hpe": "^2.3.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-is": "^17.0.2",
    "styled-components": "^5.3.3",
    "xml2js": "^0.4.23"
  },
  "devDependencies": {
    "parcel": "^2.4.0"
  }
}

ran:

$ yarn install
$ yarn parcel ./src/index.html

🤔 Expected Behavior

  1. no yarn warnings / errors
  2. build should succeed and dev web site should load

😯 Current Behavior

I get the following output from yarn install:

clarkl@ubuntu:~/src/ehymnal$ yarn install
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @parcel/optimizer-image@npm:2.4.0 doesn't provide @parcel/core (p44b39), requested by @parcel/workers
➤ YN0002: │ @parcel/transformer-image@npm:2.4.0 doesn't provide @parcel/core (p520b2), requested by @parcel/workers
➤ YN0002: │ @parcel/transformer-js@npm:2.4.0 doesn't provide @parcel/core (pbc763), requested by @parcel/workers
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p3763a), requested by @parcel/fs
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p4a530), requested by @parcel/workers
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (pce8d5), requested by @parcel/cache
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p920a9), requested by @parcel/package-manager
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 541ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 2s 295ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed in 0s 358ms
➤ YN0000: Done with warnings in 3s 290ms

Output from yarn parcel ./src/index.html:

clarkl@ubuntu:~/src/ehymnal$ yarn parcel src/index.html
Server running at http://localhost:1234
🚨 Build failed.

@parcel/transformer-js: Could not resolve module "@parcel/core" from
"/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-workers-virtual-b894a7519c/0/cache/@parcel-workers-npm-2.4.0-02c678f07b-1133365fb3.zip/node_modules/@parcel/workers/lib/Handle.js"

  Error: Could not resolve module "@parcel/core" from
  "/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-workers-virtual-b894a7519c/0/cache/@parcel-workers-npm-2.4.0-02c678f07b-1133365fb3.zip/node_modules/@parcel/workers/lib/Handle.js"
  at $0578d0f6e116167e$export$fb2a0b866a8162dc.resolve
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-package-manager-virtual-61561ddc50/0/cache/@parcel-package-manager-npm-2.4.0-400bc2f526-89104ec718.zip/node_modules/@parcel/package-manager/lib/index.js:4919:21)
  at NodePackageManager.resolveSync
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-package-manager-virtual-61561ddc50/0/cache/@parcel-package-manager-npm-2.4.0-400bc2f526-89104ec718.zip/node_modules/@parcel/package-manager/lib/index.js:3510:42)
  at NodePackageManager.requireSync
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-package-manager-virtual-61561ddc50/0/cache/@parcel-package-manager-npm-2.4.0-400bc2f526-89104ec718.zip/node_modules/@parcel/package-manager/lib/index.js:3351:34)
  at Module.m.require
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-package-manager-virtual-61561ddc50/0/cache/@parcel-package-manager-npm-2.4.0-400bc2f526-89104ec718.zip/node_modules/@parcel/package-manager/lib/index.js:3365:25)
  at require (node:internal/modules/cjs/helpers:102:18)
  at _core
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-workers-virtual-b894a7519c/0/cache/@parcel-workers-npm-2.4.0-02c678f07b-1133365fb3.zip/node_modules/@parcel/workers/lib/Handle.js:9:16)
  at Object.<anonymous>
  (/home/clarkl/src/ehymnal/.yarn/__virtual__/@parcel-workers-virtual-b894a7519c/0/cache/@parcel-workers-npm-2.4.0-02c678f07b-1133365fb3.zip/node_modules/@parcel/workers/lib/Handle.js:57:5)
  at Module._compile (node:internal/modules/cjs/loader:1103:14)
  at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
  at Object.require$$0.Module._extensions..js (/home/clarkl/src/ehymnal/.pnp.cjs:12009:33)

The dev server at http://localhost:1234 is inaccessible from Chrome:

"This site can't be reached. localhost refused to connect"

💁 Possible Solution

🔦 Context

I'm trying to deploy my React app using netlify, and this was reviewed favorably as a simple, zero-config, way to do that.

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 2.4.0
Node v16.14.2
npm/Yarn 3.2.0
Operating System Ubuntu 20.04
@clarktlaugh
Copy link
Author

clarktlaugh commented Mar 31, 2022

I can manually add @parcel/core as a dependency and do not get any build issues, but still see the yarn warnings:

$ yarn add @parcel/core --dev
➤ YN0000: ┌ Resolution step
➤ YN0002: │ @parcel/optimizer-image@npm:2.4.0 doesn't provide @parcel/core (p44b39), requested by @parcel/workers
➤ YN0002: │ @parcel/transformer-image@npm:2.4.0 doesn't provide @parcel/core (p520b2), requested by @parcel/workers
➤ YN0002: │ @parcel/transformer-js@npm:2.4.0 doesn't provide @parcel/core (pbc763), requested by @parcel/workers
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p3763a), requested by @parcel/fs
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p4a530), requested by @parcel/workers
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (pce8d5), requested by @parcel/cache
➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p920a9), requested by @parcel/package-manager
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 646ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 858ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed in 0s 234ms
➤ YN0000: Done with warnings in 1s 801ms
$ yarn parcel src/index.html
Server running at http://localhost:1234
✨ Built in 15.03s

@tfrijsewijk
Copy link

I am build a library with several entrypoints using "source": ["src/entrypoint1.ts", "src/entrypoint2"] in package.json.

I only have a devDependency on Parcel, no dependency on @parcel/core. Everything works (watching + building) but I'm seeing the same yarn warnings:

                 [exec] ➤ YN0000: ┌ Resolution step
                 [exec] ➤ YN0002: │ @parcel/optimizer-image@npm:2.4.0 doesn't provide @parcel/core (p44b39), requested by @parcel/workers
                 [exec] ➤ YN0002: │ @parcel/transformer-image@npm:2.4.0 doesn't provide @parcel/core (p520b2), requested by @parcel/workers
                 [exec] ➤ YN0002: │ @parcel/transformer-js@npm:2.4.0 doesn't provide @parcel/core (pbc763), requested by @parcel/workers
                 [exec] ➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p3763a), requested by @parcel/fs
                 [exec] ➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p4a530), requested by @parcel/workers
                 [exec] ➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (pce8d5), requested by @parcel/cache
                 [exec] ➤ YN0002: │ @parcel/types@npm:2.4.0 doesn't provide @parcel/core (p920a9), requested by @parcel/package-manager

@Lazerbeak12345
Copy link

From my testing, this error is only blocking if yarn is using strict pnp mode.

Here's yarn's documentation page about pnp mode: https://yarnpkg.com/features/pnp

The issue would probably be fixed by marking @parcel/core a direct dependency instead of a peer dependency in these modules:

  • @parcel/workers
  • @parcel/fs
  • @parcel/cache
  • @parcel/package-manager

@mischnic
Copy link
Member

mischnic commented Apr 2, 2022

The reason it's a peer dependency in the first place is that these four packages call a function in @parcel/core

registerSerializableClass(`${packageJson.version}:FSCache`, FSCache);

and if they there are multiple instances of @parcel/core involved, then there'll be an error at runtime become something wasn't registered.

@Lazerbeak12345
Copy link

Hmm... that's what I had feared. I'm surprised that yarn considers this an error, as this is a very valid use-case of peerDependancies.

@Lazerbeak12345
Copy link

Lazerbeak12345 commented Apr 2, 2022

For now, if anyone else runs into this issue while a long-term solution brews, I'd recommend looking at this part of the docs:

https://yarnpkg.com/getting-started/migration#fix-dependencies-with-packageextensions

I used that to generate this text to put in my .yarnrc.yml

packageExtensions:
  "@parcel/[email protected]":
    dependencies:
      "@parcel/core": "2.4.1"
  "@parcel/[email protected]":
    dependencies:
      "@parcel/core": "2.4.1"
  "@parcel/[email protected]":
    dependencies:
      "@parcel/core": "2.4.1"
  "@parcel/[email protected]":
    dependencies:
      "@parcel/core": "2.4.1"

Keep in mind that the above is a short-term solution.

@stephank
Copy link

stephank commented May 3, 2022

The issue here, from Yarn's perspective, is that @parcel/transformer-js depends on @parcel/workers without fulfilling the @parcel/core peer dependency. Peer dependencies in Yarn need to be satisfied by the immediate dependant, and not just somewhere (multiple steps) up the dependency chain.

Some of this was already fixed in 2.5.0, via #7977, including the specific case reported here. But @parcel/optimizer-image and @parcel/types are still not set up correctly.

@github-actions github-actions bot added the Stale Inactive issues label Oct 31, 2022
@mischnic mischnic removed the Stale Inactive issues label Oct 31, 2022
@parcel-bundler parcel-bundler deleted a comment from github-actions bot Oct 31, 2022
@github-actions github-actions bot added the Stale Inactive issues label Apr 29, 2023
@noahtallen
Copy link

This is still an issue, which is unfortunate as these warnings are the default behavior when running the recommended setup command with the current version of Yarn

@github-actions github-actions bot removed the Stale Inactive issues label May 6, 2023
@noahtallen
Copy link

See #6727 as well

@amartincolby
Copy link

Is there a roadmap or any other discussions around this? I have the privilege of some greenfield work and very much want Parcel combined with no-install Yarn but would rather not distribute a library to teams with workarounds in it.

@mischnic
Copy link
Member

mischnic commented Jun 3, 2023

See #9070 and #6727 (comment) . These should cover all remaining problems

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.

7 participants