NextJS Rewrites TypeError: (0 , _resolveRewrites.default) is not a function

NextJS Rewrites TypeError: (0 , _resolveRewrites.default) is not a function

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

这是我的next.config.js

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

这是我得到的错误
TypeError: (0 , _resolveRewrites.default) 不是函数

Next.config.js Code
The Error

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

有一个快速修复方法:

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

如果上述方法无法解决问题,请尝试将 nextjs 包升级到 10.2.0npm install next@latest

我有同样的问题,不幸的是@Mic 的解决方案对我不起作用,但是当我首先清理缓存时它起作用了所以 运行 按顺序

那么如果你使用纱线:

yarn cache clean

rm -rf node_modules yarn.lock && yarn install

或者如果您使用的是 npm:

npm cache clean

rm -rf node_modules package-lock.json && npm install

如果@MicFung 的快速修复不起作用,请尝试使用 yarn

  • 删除 node_modules
  • 删除包-lock.json 和/或删除yarn.lock
  • 纱线安装