![](/img/trans.png)
[英]Next.js Import image error Module parse failed: Unexpected character '�' (1:0)
[英]Next.js _app.js: Module parse failed: Unexpected token on fresh project
我使用以下方法创建了一个新的 Next.js 项目:
npx create-next-app
然后我进入文件夹,运行npm run dev
并收到以下错误:
C:/Users/mikke/Documents/Projects/next-project/pages/_app.js 4:9
Module parse failed: Unexpected token (4:9)
You may need an appropriate loader to handle this file type, currently no loaders are
configured to process this file. See https://webpack.js.org/concepts#loaders
|
| function MyApp({ Component, pageProps }) {
> return <Component {...pageProps} />
| }
|
非常困惑为什么会这样。 我首先得到错误部署然后克隆这个例子: https://github.com/supabase/supabase/tree/master/examples/nextjs-todo-list
我也尝试删除 node_modules 和 ./next 并重新安装依赖项,但没有运气。 我错过了什么?
编辑:我的 _app.js(与 create-next-app 默认值完全相同)
import '../styles/globals.css'
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
export default MyApp
对于可能遇到此问题的其他人,解决方案(至少对我而言)是在 vscode 的终端中运行命令。 欲了解更多信息: https://github.com/vercel/next.js/issues/16535
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.