The browser appears to read the JavaScript file as HTML and receives "Uncaught SyntaxError: Unexpected token '<'"
P粉520545753
P粉520545753 2023-09-05 13:59:44
0
1
476

Similar to this unanswered question: Browsers appear to read React JS files as HTML, not JSX

I have a project built using Next.js, React, and Typescript.

But now I'm trying to add some Javascript files like testScroll.js:

function init() { window.scrollTo(0, 1); window.scrollTo(0, -1); console.log('scrolling') } init()

I saved this script at public/js/testScroll.js. I try to use it on this index.tsx component:

import { type NextPage } from "next"; import { Footer, Header, HomePageWrapper } from "~/componentsFromWebflow/homeComponents"; import Script from "next/script"; import Head from "next/head"; const Home: NextPage = () => { return ( <>   Ace-it