Unable to import createClient from prismicio

Hey there,

Please do bare with me as I am a designer learning to code.

I am trying to use Prismic in a project to learn how to create next.js sites and webapps.

I'm getting pretty stuck early on when it comes to importing createClient from prismicio

I'm following this guide. Fetch Data in Next.js - Documentation - Prismic

I get the following warning:

./pages/index.js:6:0
Module not found: Can't resolve '@/prismicio'

I've also tried import { createClient } from "../prismicio"; which then leads to another error.

The code I am using createClient for is the following:

export async function getServerSideProps(ctx){
  const client = createClient();
  const homepage = await client.getSingle('homepage');
  console.log(homepage)
  return {
    props:{}
  }
}

and I get the following errors on my localhost:

Any ideas what I could be doing wrong here?

Some more info:

I've also tried following this guide here: https://www.locofy.ai/blog/building-a-blog-app-from-a-figma-design-with-locofy.ai

Where I run into the same issues.

Here is an image of the custom type:

Hi Will,
I have seen this issue before. Check your prismicio.js file and look for your route resolver.
Comment out your page route, and leave the homepage route there:


const routes = [
  {
    type: 'homepage',
    path: '/',
  },
  // {
    // type: 'page',
    // path: '/:uid',
  // },
]

Let me know if that helps.

Another possible reason behind that error message is having no documents published of the custom type which it says is declared but unknown (i.e. 0 published documents of page customType)

Thanks for the replies folks. The issue lay with the route resolver in this case. Something I seem to have issues getting my head around