Search code examples
javascriptreactjswebpackbabeljsnext.js

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


I got an Error when using Rewrites in NextJS by using references in NextJS Documentation
I tried to reinstall node_modules but it still not working
Enviroment Variables is working, but rewrites feature is not working

This is my next.config.js

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

This is the error what i got
TypeError: (0 , _resolveRewrites.default) is not a function

Next.config.js Code
The Error


Solution

  • I encountered this problem before with a clean nextjs project.

    There is a quick fix:

    • Remove the node_modules
    • Remove package-lock.json
    • npm install again.

    If the above cannot help, please try to upgrade the nextjs package to 10.2.0, npm install next@latest