【发布时间】:2019-09-23 01:30:53
【问题描述】:
在我的 next.js 应用程序中执行 next build 时,我收到以下错误,在它仅使用 next(或 npm run dev)工作正常之后。
错误:
$ next build
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react-dom'
Creating an optimized production build ...
> Using external babel configuration
> Location: "../.babelrc"
Failed to compile.
./pages/_app.js
Module not found: Can't resolve 'next/head' in '../pages'
> Build error occurred
Error: > Build failed because of webpack errors
at build (.../AppData/Roaming/npm/node_modules/next/dist/build/index.js:7:847)
我通过克隆 Material UI 的 next.js 示例开始了我的项目,并在它看起来更新时使用它:
https://github.com/mui-org/material-ui/tree/master/examples/nextjs
但是,我认为我可能只是有一个过时或损坏的构建,我重新克隆了 next.js 示例并做了next build,没有修改任何文件,我得到了同样的错误。
我该如何解决这个问题?
【问题讨论】:
标签: javascript reactjs next.js