我想在 nextjs 應用程式中升級到 React 18。我按照官方檔案中的說明進行操作。
npm install next@latest react@latest react-dom@latest
但是當我嘗試運行時,npm run build我得到了錯誤:
/node_modules/next/dist/build/index.js:329
...pageKeys.app ?? [],
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
我試圖用谷歌搜索這個錯誤,但沒有運氣
uj5u.com熱心網友回復:
當前的 next.js (13.0.0) 需要節點 14.6.0 或更高版本:
系統要求
- Node.js 14.6.0或更高版本
- 支持 MacOS、Windows(包括 WSL)和 Linux
您看到的錯誤是因為一些 next.js 代碼使用了nullish coalescing operator。這種語言結構是在節點 14.0.0中引入的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/520564.html
標籤:反应下一个.js
