Home > Net >  nuxt fails with an error not being able to parse source for import analysis
nuxt fails with an error not being able to parse source for import analysis

Time:01-19

When I attempt to make the server, it throws up a 500 error and the following error is shown in the terminal:

[SSR] Error transforming  virtual:C:/Users/User/Documents/CODING/Ted's/.nuxt/plugins/server.mjs: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.

I've attempted to run npm cache clean --force I've reinstalled npm numerous times, given Everyone full privs for the dir it is in, ran VSCode as admin, I'm out of ideas.

CodePudding user response:

The problem is most certainly related to those issues:

This PR addresses issues when using rollup for a project with ' in the path, for example /Users/Daniel's Projects/project/. Although normal imports are escaped correctly, it seems that dynamic imports are treated differently and we need to escape them as well.

Your path C:/Users/User/Documents/CODING/Ted's/ contains a ' and according to the issue this results in that problem.

So the solution to the problem is to get rid of that ' in your path, or wait until a version of nuxt is released that fixes that problem.

given Everyone full privs for the dir it is in, ran VSCode as admin, I'm out of ideas.

That is something you should never do. There are only really rare cases where you probably might need that, and even then you should rethink that multiple times. Running VSCode as admin would allow vscode and all its installed plugins to mess around with a large amount of the system. If you do that you need to fully trust all of those.

CodePudding user response:

Change the filename from server.mjs to server.js and try again :D.

  •  Tags:  
  • Related