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

The React module does not support Yarn >v1. #1711

Open
quisido opened this issue Feb 1, 2025 · 0 comments
Open

The React module does not support Yarn >v1. #1711

quisido opened this issue Feb 1, 2025 · 0 comments

Comments

@quisido
Copy link

quisido commented Feb 1, 2025

I'm using Yarn 4.6, and posthog-js fails because react is not declared as a peer dependency (or dependency).

Here's the error as it comes from GitHub Actions CI:

Error: posthog-js tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.%0A%0ARequired package: react%0ARequired by: posthog-js@npm:1.214.0 (via /home/runner/.yarn/berry/cache/posthog-js-npm-1.214.0-b6fee74acf-10c0.zip/node_modules/posthog-js/react/dist/umd/)%0A%0ARequire stack:%0A- /home/runner/.yarn/berry/cache/posthog-js-npm-1.214.0-b6fee74acf-10c0.zip/node_modules/posthog-js/react/dist/umd/index.js%0A ❯ Function.require$$0.Module._resolveFilename ../../.pnp.cjs:34662:13%0A ❯ Function.require$$0.Module._load ../../.pnp.cjs:34553:31%0A ❯ ../../../../../.yarn/berry/cache/posthog-js-npm-1.214.0-b6fee74acf-10c0.zip/node_modules/posthog-js/react/dist/umd/index.js:2:108%0A%0A⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯%0ASerialized Error: { code: 'MODULE_NOT_FOUND', pnpCode: 'UNDECLARED_DEPENDENCY', data: { request: 'react', issuer: '/home/runner/.yarn/berry/cache/posthog-js-npm-1.214.0-b6fee74acf-10c0.zip/node_modules/posthog-js/react/dist/umd/', issuerLocator: { name: 'posthog-js', reference: 'npm:1.214.0' }, dependencyName: 'react' }, requireStack: [ '/home/runner/.yarn/berry/cache/posthog-js-npm-1.214.0-b6fee74acf-10c0.zip/node_modules/posthog-js/react/dist/umd/index.js' ] }%0A

You may be looking for peerDependenciesMeta, since you are vending multiple library integrations in a single package: https://stackoverflow.com/questions/62047806/how-do-i-set-a-peer-dependency-optional

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

No branches or pull requests

1 participant