NextJS 重写 TypeError: (0 , _resolveRewrites.default) 不是函数

Fen*_*ndy 6 javascript reactjs webpack babeljs next.js

我通过使用 NextJS 文档中的引用在 NextJS 中使用重写时出现错误
我尝试重新安装 node_modules 但它仍然不起作用
环境变量正在工作,但重写功能不起作用

这是我的 next.config.js

module.exports = {
  env: {
    APPNAME: 'NextJS Exercise!!!',
  },
  async rewrites() {
    return [
      {
        source: '/login',
        destination: '/auth/login',
      }, 
    ]
  },
}

Run Code Online (Sandbox Code Playgroud)

这是我得到的错误
TypeError: (0 , _resolveRewrites.default) is not a function

Next.config.js 代码
错误

Mic*_*ung 13

我之前在一个干净的 nextjs 项目中遇到过这个问题。

有一个快速修复方法:

  • 删除node_modules
  • 删除 package-lock.json
  • npm install再次。

如果上述方法无法帮助您,请尝试将nextjs包升级到10.2.0npm install next@latest