4

I'm working on a Nuxt 4 project and sometimes, after I update a file, J got the following error in the browser console:

Uncaught (in promise) SyntaxError: Identifier 'validate' has already been declared (at virtual:nuxt:/home/nicolas/Desktop/projets-web/wimefront/.nuxt/middleware.mjs:2:1)

Inspecting the generated .nuxt/middleware.mjs, I can see this:

 import validate from "/_nuxt/@fs/home/nicolas/Desktop/projets-web/wimefront/node_modules/nuxt/dist/pages/runtime/validate.js?v=3712f6c6";
    import validate from "/_nuxt/@fs/home/nicolas/Desktop/projets-web/wimefront/node_modules/nuxt/dist/pages/runtime/validate.js?v=3712f6c6"; // duplicated
    import manifest_45route_45rule from "/_nuxt/@fs/home/nicolas/Desktop/projets-web/wimefront/node_modules/nuxt/dist/app/middleware/manifest-route-rule.js?v=3712f6c6";

export const globalMiddleware = [
  validate,
  validate,
  manifest_45route_45rule
];

export const namedMiddleware = {
  auth: () => import("/_nuxt/middleware/auth.js")
};

I do not have any validate.js or validate.ts in my middleware/ or pages/ folder. I only have one custom middleware file, and it doesn't export or declare anything named validate.

I’ve tried:

rm -rf .nuxt node_modules + fresh npm install

Confirming I have no duplicate files named validate

Still, Nuxt seems to import the same internal validate.js file twice and crashes.

Almost every time I change something in a vue file, I need to do npm dev again (after npm dev I don't have the error)

Any clue?

4
  • This looks more like a bug than a Stack Overflow question. You should probably open an issue in the Nuxt repository with a minimal reproduction. Commented Jul 28 at 9:10
  • have you solved the problem? i am facing the same issue, it is almost impossible to developer in this way.... Commented Aug 5 at 21:36
  • Same issue here? Someone have solved that problem? Commented Aug 16 at 23:02
  • Im with the same problem here, did you already found a solution? Commented Sep 16 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.