triggerdotdev / trigger.dev

Trigger.dev is the open source background jobs platform.
https://trigger.dev/changelog
Apache License 2.0
9.43k stars 591 forks source link

bug: Error: Unable to resolve module @trigger.dev/core/v3 #1490

Open maxckelly opened 3 days ago

maxckelly commented 3 days ago

Provide environment information

"@trigger.dev/react-hooks": "^3.2.1", React native

Describe the bug

Hi - I'm trying to use the react hooks as stated in the documentation but whenever I try to call authentication or subscribe I get the below error. Can someone please help.

Error: Unable to resolve module @trigger.dev/core/v3 from /Users/USER/other/PROJECT/node_modules/@trigger.dev/react-hooks/dist/commonjs/hooks/useApiClient.js: @trigger.dev/core/v3 could not be found within the project or in these directories:
  node_modules
  3 | Object.defineProperty(exports, "__esModule", { value: true });
  4 | exports.useApiClient = useApiClient;
> 5 | const v3_1 = require("@trigger.dev/core/v3");
    |                       ^
  6 | const contexts_js_1 = require("../contexts.js");
  7 | /**
  8 |  * Hook to create an API client instance using authentication context or provided options.
    at ModuleResolver.resolveDependency (Users/USER/other/PROJECT/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:138:15)
    at DependencyGraph.resolveDependency (Users/USER/other/PROJECT/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at Users/USER/other/PROJECT//node_modules/metro/src/lib/transformHelpers.js:156:21
    at resolveDependencies (Users/USER/other/PROJECT/node_modules/metro/src/DeltaBundler/buildSubgraph.js:42:25)
    at visit (Users/USER/other/PROJECT/node_modules/metro/src/DeltaBundler/buildSubgraph.js:83:30)
    at async Promise.all (index 1)
    at async visit (/Users/USER/other/PROJECT/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 17)
    at async visit (Users/USER/other/PROJECT/node_modules/metro/src/DeltaBundler/buildSubgraph.js:92:5)
    at async Promise.all (index 7)

Reproduction repo

https://github.com/triggerdotdev/trigger.dev

To reproduce

Build react native application and install package as stated in docs

Additional information

No response

Cirr0e commented 18 hours ago

Hi there! I understand you're encountering a module resolution error while trying to use @trigger.dev/react-hooks in your React Native project.

The error you're seeing suggests there's a compatibility issue between the React Native environment and the @trigger.dev packages. Looking at the underlying issue, this is happening because @trigger.dev/react-hooks is trying to import from @trigger.dev/core/v3, but this dependency isn't being resolved correctly in the React Native environment.

Here's what I suggest to resolve this:

  1. First, make sure you have all the necessary dependencies installed:

    npm install @trigger.dev/react-hooks@3.2.1 @trigger.dev/core@3.2.1
  2. Since you're using React Native, you'll need to add the core package explicitly to your dependencies in package.json:

    {
    "dependencies": {
    "@trigger.dev/react-hooks": "^3.2.1",
    "@trigger.dev/core": "^3.2.1"
    }
    }
  3. After updating your dependencies, clear your React Native bundler cache:

    # For Metro bundler
    npx react-native start --reset-cache

Important considerations:

If you're still experiencing issues after trying these steps, please let me know:

  1. What version of React Native you're using
  2. Your metro.config.js configuration (if you have customized it)
  3. Whether you're using Expo or bare React Native

The error appears to be a module resolution issue rather than a functional one, so once we get the packages properly resolved, you should be able to use the React hooks as documented.

Let me know if you need any clarification or run into other issues!