question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to parse source for import analysis because the content contains invalid JS syntax

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: npm@8.5.5
  • Builder: vite
  • User Config: nitro, typescript
  • Runtime Modules: -
  • Build Modules: -

Reproduction

build the project with npm run build

Describe the bug

When running npm run build i see the following message. I don’t know which file the error is referring to

Additional context

No response

Logs

ERROR  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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
codefloristcommented, Jun 10, 2022

on my end this error occurs, if single quotes are used in the src of a font-face declaration:

@font-face {
	font-family: "Open Sans";
	src: url('/fonts/open-sans-v16-latin-300.woff2') format('woff2');
}

if this is changed to double quotes, the error vanishes:

@font-face {
	font-family: "Open Sans";
	src: url("/fonts/open-sans-v16-latin-300.woff2") format("woff2");
}
1reaction
danielroecommented, Jun 8, 2022

This is coming from Vite (though perhaps because of a transform that Nuxt is doing). I agree that there should be a better error message that indicates (at least) which source file the issue is coming from. It would be worth raising that as an issue at https://github.com/vitejs/vite.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to parse source for import analysis because the content ...
Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name...
Read more >
javascript - plugin:vite:import-analysis - Failed to parse source ...
Failed to parse source for import analysis because the content contains invalid JS syntax. There's nothing wrong in i18n.js file as it was ......
Read more >
vite failed to parse source for import analysis ... - You.com
Hi, got this error Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install...
Read more >
[plugin:vite:import-analysis] Failed to parse source for ... - Reddit
[plugin:vite:import-analysis] Failed to parse source for import analysis because the content contains invalid JS syntax.
Read more >
Unable to return HTML in Vue component - Laracasts
[plugin:vite:import-analysis] Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found