![](/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.