在使用vite工具開發(fā)Vue.js 3.0項目時,由于配置問題,導致了項目運行報錯,錯誤提示如下:
Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.
12:08:44 [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.
解決方法
1、 首先安裝依賴插件
npm install @vitejs/plugin-vue -D
2、接著配置vite項目配置文件:vite.config.js
// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
});
3、重新運行
npm run dev
解決!文章來源地址http://www.zghlxwxcb.cn/news/detail-572686.html
文章來源:http://www.zghlxwxcb.cn/news/detail-572686.html
到了這里,關于[vite]:報錯Failed to parse source for import analysis because the content contains invalid JS syntax.的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!