defu__WEBPACK_IMPORTED_MODULE_3__ is not a function

Viewed 313

Has anyone ever encountered this error when using nuxt-auth from this official guide? How did you solve it? I'm stuck here for days.

The error is defu__WEBPACK_IMPORTED_MODULE_3__ is not a function

1 Answers

Ran into a similar warning with React early this week, It means you are trying to call a function/access a property of a module that you imported but imported wrongly or it is not exported from the module. webpack throws that error: Similar problem was:

// inside get-user.js
const getUser = () => { 
  const result = localStorage.getItem('user')
  if(result) return JSON.parse(result)
  else return null
}
// Notice: missing export

// inside App.jsx
import getUser from './get-user'
const App = () => {
  const user = getUser()
}

As you can see, inside get-user.js it slipped my mind to add an export for the getUser function. Webpack bundles this but fails later on when I load the App component. A possible cause for your issue:

  1. Missing export for a reusable module you have written.
  2. An issue with next-auth version you are using, Some libraries have breaking changes in a major release, for example, new versions of node-fetch is shipped as ES6 module by default, suggestion is to switch to a lower version(stable) of the package.
  3. Check your export/imports relating to that module in your code if they are correct.

Let me know if that helps, Happy coding!

Related