10000 Error: Failed to resolve entry for package "@revenuecat/purchases-capacitor" when running "vitest" · Issue #396 · RevenueCat/purchases-capacitor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Error: Failed to resolve entry for package "@revenuecat/purchases-capacitor" when running "vitest" #396

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

Open
OkkioXavier opened this issue Feb 15, 2025 · 5 comments

Comments

@OkkioXavier
Copy link
OkkioXavier commented Feb 15, 2025

Summary

When running vitest an error is thrown: Error: Failed to resolve entry for package "@revenuecat/purchases-capacitor". The package may have incorrect main/module/exports specified in its package.json.

This is blocking for us as it prevents our unit tests from succeeding in CI.

Version

10.0.2

Minimal Reproduction

Run npm run test.unit

https://github.com/OkkioXavier/revenue-cat-missing-main-target

Symptoms

When running npm run test.unit in the ionic example project with revenuecat configured I get the following error:

Error: Failed to resolve entry for package "@revenuecat/purchases-capacitor". The package may have incorrect main/module/exports specified in its package.json.
❯ packageEntryFailure node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:49442:17
❯ resolvePackageEntry node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:49439:5
❯ tryNodeResolve node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:49209:20
❯ Context.resolveId node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:48959:28
❯ Object.resolveId node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:52242:32
❯ TransformContext.resolve node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:51933:23
❯ normalizeUrl node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:67301:34
❯ async file:/***/revenue-cat-missing-main-target/myApp/node_modules/vite/dist/node/chunks/dep-p3C6MpSJ.js:67465:47

The only change I have made to the base template is to add the following lines to App.tsx

await Purchases.setLogLevel({level: LOG_LEVEL.DEBUG}); // Enable to get debug logs
await Purchases.configure({
  apiKey: '',
  appUserID: '' // Optional
})

Possible cause

The file "dist/plugin.cjs.js" does not exist in the package but is defined in package.json as the entry point in package.json

Modifying main from:

{
  "name": "@revenuecat/purchases-capacitor",
  "version": "10.0.2",
  "description": "Capacitor in-app purchases and subscriptions made easy. Support for iOS and Android.",
  "main": "dist/plugin.cjs.js",
  "module": "dist/esm/index.js",
  "types": "dist/esm/index.d.ts",
  "unpkg": "dist/plugin.js"
...
}

to

{
  "name": "@revenuecat/purchases-capacitor",
  "version": "10.0.2",
  "description": "Capacitor in-app purchases and subscriptions made easy. Support for iOS and Android.",
  "main": "dist/esm/index.js"
  "module": "dist/esm/index.js",
  "types": "dist/esm/index.d.ts",
  "unpkg": "dist/plugin.js"
}

gives me the expected error: Web not supported in this plugin.

@RCGitBot
Copy link
Collaborator

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@hedinasr
Copy link

I have the same problem, fixing the package.json works.

@Jethro87
Copy link

Thanks for reporting this and for the minimal reproduction project. Our team is reviewing this.

@distante
Copy link

Does this means unit test is not possible currently?

I want to migrate from another solution because their testing environment does not really work as it should and I really do not want to land in the same problem.

@davidjmstewart
Copy link

I've just encountered this problem. Any solutions?

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

6 participants
0