Open Gstark10 opened 1 year ago
hi, @Gstark10 can you be more specific with your error, so that we can help you with you can give a screenshot or a code demonstration.
hi @SoumyaSubhrajit this is my problem... error - ./src/pages/_app.tsx:4:12 Syntax error: Unexpected token, expected "from"
2 | 3 | import '@/styles/globals.css'
4 | import type { AppProps } from 'next/app' | ^ 5 | 6 | function App({ Component, pageProps }: AppProps) {
7 | return <Component {...pageProps} /> wait - compiling... error - ./src/pages/_app.tsx:4:12 Syntax error: Unexpected token, expected "from"
2 | 3 | import '@/styles/globals.css'
4 | import type { AppProps } from 'next/app' | ^ 5 | 6 | function App({ Component, pageProps }: AppProps) {
7 | return <Component {...pageProps} /> wait - compiling... error - ./src/pages/_app.tsx:4:12 Syntax error: Unexpected token, expected "from"
2 | 2 | 3 | import '@/styles/globals.css'
4 | import type { AppProps } from 'next/app' | ^ 5 | 6 | export default function App({ Component, pageProps }: AppProps) { 7 | return <Component {...pageProps} />
@Gstark10 1) The error we are seeing here Missing import statement: If the code on line 4 of _app.tsx relies on an external module, but the module is not imported at the top of the file, the parser may not be able to recognize the syntax. To fix this, make sure to add an import statement at the top of the file for any modules that the code on line 4 depends on.
2) If the imported statement is incorrect then the parser may not be able to recognize it,so double-check the value in the above import statement I think the issue we are facing in the import statement or any missing of marks, brackets, or curly braces, and let me know the though you get the solution or not.
@SoumyaSubhrajit ok...lemme check it..thanks so much
@SoumyaSubhrajit sorry for disturbing you..pls i need help with this
hi, @Gstark10 I see the above error, my guess is that error might be the import of sanity is not proper means ex-> import sanityClient from '@sanity/client';
do you import properly?
If you imported properly make sure that you install the latest sanity package like npm install --save-dev @sanity/cli@latest
.
If you still facing any error, you can reach me😄.
@SoumyaSubhrajit Am still having errors, if you look at his code @lib/clientjs he did this : export const client = sanityClient({ projectId: 'vfxfwnaw', dataset: 'production', apiVersion: '2022-03-10', useCdn: true, token: process.env.NEXT_PUBLIC_SANITY_TOKEN )}
I did the same thing but got this error Server Error TypeError: (0 , _sanity_client__WEBPACK_IMPORTED_MODULE_0__.sanityClient) is not a function
@Gstark10
1) This error may occur during the installation of sanity, have you done right while installing the sanity client?
2) check process.env.NEXT_PUBLIC_SANITY_TOKEN
This one save in the .env right but the value of
NEXT_PUBLIC_SANITY_TOKEN
will be taken manually just right the cmd npm i dotenv
you can google it what is .env
files.
3) The main reason is:
add apiVersion in your code like this.
export const client = sanityClient({
projectId: 'vfxfwnaw',
dataset: 'production',
apiVersion: '2023-04-28', // CHANGE IT TO TODAY'S DATE
useCdn: true,
token: process.env.NEXT_PUBLIC_SANITY_TOKEN
)}
check it once.
@SoumyaSubhrajit bruv..about installing the dependencies he run install --legacy-peer-deps And it installed all the dependencies,..but i did the same thing and it did not install the dependencies,so i had to install it one by one... maybe that's why when i import it,...it will be showing error.
@SoumyaSubhrajit mehn so many Errors,it is so frustrating....once u follow the videos all u get is errors .
@Gstark10 I feel your pain bruh just install all dependency and try to install manually may be it could solve your problem.
@SoumyaSubhrajit actually i started afresh,he ran npm install --legacy-peer-deps and install all dependencies like sanity/client and so on but mine didnot install it
@SoumyaSubhrajit Are you on twitter i gat to follow u up cus i got alot of questions to ask... i think my problem generally is because i'm making use of react 18 and that project was built with react17...so alot of things he did was already outdated in mine...and i tried downgrading to react17 but it was not really successful cus nextjs insisted i install react18..so what do i do right now???
@Gstark10 bruh, I suggested rebuilding the entire app again might be helpful to you. my twitter acc -> https://twitter.com/SoumyaSubhrajit
pls am importing components in indexjs and it is giving me error? can someone pls help me out??