DEV Community

Saad Masood
Saad Masood

Posted on

Next.js compiler error in basic script

Can someone please tell me why the Next.js compiler cannot parse and compile a basic JSX script such as this one?

---- contents of index.js ---- file

const IndexPage = () => {
return {

Hello from Pluralsight
};
}

export default IndexPage ;

error - ./pages/index.js
Error: error: Unexpected token < (jsx tag start). Expected identifier, string literal, numeric literal or [ for the computed key

|
3 |

Hello
| ^
The error I get is:
Enter fullscreen mode Exit fullscreen mode

Caused by:
0: failed to process js file
1: Syntax Error
(node:25380) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use node --trace-deprecation ... to show where the warning was created)
wait - compiling /_error (client and server)...
error - ./pages/index.js
Error: error: Unexpected token < (jsx tag start). Expected identifier, string literal, numeric literal or [ for the computed key

|
3 |

Hello from Pluralsight
| ^

Caused by:
0: failed to process js file

I am running Next.js v12.1.0 with Node v16.14.0 on a Windows 11 professional machine.

Thanks,

Saad

Top comments (1)

Collapse
 
sedangky profile image
kouveo

Try this



const IndexPage = () => {
    return (
         <div>
                Hello from Pluralsight
         </div>
    )
}
Enter fullscreen mode Exit fullscreen mode