1

I am trying to create a Sitecore JSS app for Sitecore 10.3 with nextjs template. I keep getting the error below when I try Jss start command. I am trying to run this in disconnected mode with REST. My all other framework apps like Vue, Rest work but with Next it errors out with below error. Any suggestions on how to fix this?

Writing component builder to C:\poc\nextjs\src\temp\componentBuilder.ts Writing runtime config to C:\poc\nextjs\src\temp\config.js [ graphql-let ] Processing 2 codegen... [ graphql-let ] Error: Cannot use GraphQLObjectType "App" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.

Error: Cannot use GraphQLObjectType "App" from another module or realm.
3
  • It can be the version issue you have on your system. did you check this? stackoverflow.com/questions/69323261/… Aug 17, 2023 at 13:25
  • Don't run Next.js apps in REST or disconnected mode. It should be connected to Sitecore and use the GraphQL end points.
    – Richard Seal
    Aug 17, 2023 at 15:14
  • It is not working even in connected mode. It just stops with this error. The same works for some other developers
    – Padmaja
    Aug 17, 2023 at 16:03

1 Answer 1

0

It appears that you're encountering an issue while attempting to create a Sitecore JSS app using the nextjs template for Sitecore 10.3. The error message you provided indicates a problem related to GraphQL and the usage of the "App" GraphQLObjectType.

The specific error message, "Cannot use GraphQLObjectType 'App' from another module or realm," suggests that there might be a conflict in the dependencies of GraphQL within your project.

Here's how you could approach resolving this issue:

  1. Check Dependencies: Make sure you're not using conflicting or multiple versions of the graphql package in your project. Inconsistent versions of GraphQL can lead to unexpected issues. You can inspect your project's package.json and yarn.lock or package-lock.json files to identify potential conflicting dependencies.

  2. Resolutions: Consider using Yarn's selective version resolutions to ensure that only one version of the graphql package is used throughout your project. This can help mitigate conflicts arising from multiple versions of the same package. The error message you received provides a link to the Yarn documentation on how to set up resolutions.

  3. Dependency Tree: Examine your project's dependency tree to see if any other packages are indirectly bringing in different versions of GraphQL. You can use tools like yarn why graphql or npm ls graphql to identify which packages are depending on GraphQL and causing potential conflicts.

  4. Clean Cache: Sometimes, issues can be resolved by clearing the package manager's cache and reinstalling dependencies. You can do this by running yarn cache clean or npm cache clean followed by yarn install or npm install.

  5. Update Packages: Ensure that all the packages and dependencies in your project are up to date. Outdated packages could potentially introduce compatibility issues.

  6. Community Forums: If the issue persists, it might be helpful to consult the Sitecore community forums or any official documentation related to Sitecore JSS and Next.js integration. Others who have encountered a similar issue might have shared their solutions.

Remember to back up your project or create a snapshot before making significant changes to your dependencies, as modifying dependencies can sometimes lead to other unforeseen issues. If the problem persists, reaching out to Sitecore support or their community forums could provide you with more tailored assistance.

Hope this might help you, please let me know if you still have issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.