我最近在一个大型代码库上运行了npm update,现在vite在编译我的SFC文件时遇到了一些问题。
> bedgg-frontend@0.0.0 dev
> vite
vite v2.9.14 dev server running at:
> Local: http://localhost:3000/
> Network: use `--host` to expose
ready in 208ms.
Unexpected token (1:30)
Unexpected token (1:30) (x2)
12:14:28 PM [vite] Internal server error: Unexpected token (1:30)
Plugin: vite:vue
File: /home/ben/projects/bed.gg-frontend/src/views/Profile.vue
1 | <script setup lang="ts">
2 | import SkinViewer from "@/components/Player/SkinViewer.vue";
| ^
3 | import LineChart from "@/components/Charts/LineChart.vue";
4 | import PlayerStats from "@/components/Stats/Cards/PlayerStats.vue";
at instantiate (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:72:32)
at constructor (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:359:12)
at Object.raise (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:3339:19)
at Object.unexpected (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:3377:16)
at Object.getExpression (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:12232:12)
at Object.getExpression (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:11162:18)
at Object.parseExpression (/home/ben/projects/bed.gg-frontend/node_modules/@babel/parser/lib/index.js:16618:17)
at processExp (/home/ben/projects/bed.gg-frontend/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:4979:30)
at Array.CompilerDOM.transform.nodeTransforms (/home/ben/projects/bed.gg-frontend/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js:4949:45)
at traverseNode (/home/ben/projects/bed.gg-frontend/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2162:41)
对我来说,这似乎是一个配置错误或某种bug与vite。当我更新我从v2.9.6
到v2.9.14
。
vite配置
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { join, resolve } from "path";
export default defineConfig({
mode: "development",
server: {
port: 3000,
},
resolve: {
alias: {
"@": join(__dirname, "./src"),
},
},
plugins: [
vue(),
],
define: { "process.env": {} },
css: {
preprocessorOptions: {
scss: { additionalData: `@use "sass:math";@import "@/styles/_variables.scss";` },
},
},
});
配置:
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": ["vuetify", "node"],
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
知道为什么会发生这种情况吗?我看了很多Github问题都没有结果。
1条答案
按热度按时间tvmytwxo1#
同样的问题!
它为我奔走: