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
sanity will not run locally - "Element type is invalid ..." error when running 'npm run dev #6489
Comments
I just clone it, it was working fine with pnpm. |
@max888 how are you including Sanity component inside nextjs, from the code provided that shouldn't have any issues. Possible that the imports are incorrect in some place. If you can provide example recreating the issue it would help in debugging further. |
Hi @binoy14 I have a 'sanity' folder in the root of my nextjs application (outside of the app folder). Then I have a file located in
Then throughout the nextjs app I import the sanity client or image builder in my components using:
The weird thing is that if I extract/copy this 'sanity' folder somewhere outside of the nextjs application and run it using I will try and make an example recreating the issue to help debug. |
Do you have a |
Hi @mariuslundgard thanks for following up. I am not using typescript for my project but in my
I 'fixed' the issue by moving the sanity part into a new sub folder within the project and it worked. Seemed to me like it could have been a weird npm caching issue. Although I had tried My nextjs app folder structure was:
I then moved the |
I have a sanity project running in a subfolder of my NextJS project.
It was running fine locally then I stopped then restarted the local server with
npm run dev
and got the following error:Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
I've checked my import/exports of my schemas. They all use curly braces and use the following syntax:
Then in index.js
I tried deleting all node modules and .sanity folder then re-installing. Updated node modules etc. With no luck.
Expected behavior
The local server to run on localhost:3333
Screenshots
Which versions of Sanity are you using?
@sanity/cli (global) 3.39.0 (up to date)
@sanity/eslint-config-studio 4.0.0 (up to date)
@sanity/vision 3.39.0 (up to date)
sanity 3.39.0 (up to date)
What operating system are you using?
Mac OS Sonoma 14.2.1
Which versions of Node.js / npm are you running?
10.5.0
v20.12.2
Additional context
I'm reasonably new to React and this seems to be a common issue when importing modules using curly braces or not. However this particular issuse has me stumped as I did not change anything in the sanity project so am not sure why it's refusing to run.
The text was updated successfully, but these errors were encountered: