current position:Home>Vue failed to parse source for import analysis because the content contains invalid JS syntax

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

2022-06-24 09:43:19Chet Howe

Vue3 Build route error

Error description

  • Use vite structure vue3 Project time , Error when creating routing item
     Insert picture description here

  • Wrong content

Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
18:51:09 [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
Plugin: vite:import-analysis

Question why

  • The lack of @vitejs/plugin-vue Components , Need to be reinstalled .

Problem solving

  • install @vitejs/plugin-vue
npm install @vitejs/plugin-vue
  • reinstall npm
npm i
  • Created in the root directory vite.config.js

 Insert picture description here

// vite.config.js
import {
     defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    
  plugins: [vue()]
})
  • restart
npm run dev

copyright notice
author[Chet Howe],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/175/202206240825074234.html

Random recommended