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

时间:2021-05-14 04:26:09

标签: javascript reactjs webpack babeljs next.js

通过使用 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

3 个答案:

答案 0 :(得分:2)

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

有一个快速修复:

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

如果以上方法不能解决,请尝试将nextjs包升级到10.2.0npm install next@latest

答案 1 :(得分:0)

我遇到了同样的问题,不幸的是,@Mic 的解决方案对我不起作用,但是当我先清理缓存时,它会起作用,因此请按顺序运行

如果你使用纱线:

=$B$7*D2/sum($D$2:$D$5)

yarn cache clean

或者如果您使用的是 npm:

rm -rf node_modules yarn.lock && yarn install

npm cache clean

答案 2 :(得分:0)

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

  • 删除 node_modules
  • 删除 package-lock.json 和/或删除 yarn.lock
  • 纱线安装
相关问题