While executing the command vite build
, the build process fails with the error message
Expected ">" but found "setup"
. Surprisingly, this issue even occurs when using the default HelloWorld.vue
component (which is included in the Vite + Vue TS sample project).
<!-- Badge.vue -->
<script setup lang="ts">
console.log("help me")
</script>
<template>
Irrelevant
</template>
// vite.config.ts
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
build: {
rollupOptions: {
input: {
["main"]: "src/main.ts",
// Add new pages here
["pages/Badge"]: "src/pages/Badge.vue",
},
output: {
entryFileNames: "[name].mjs",
chunkFileNames: "[name].mjs",
assetFileNames: "assets/[name].[ext]",
}
}
}
})
The error can be avoided if:
- There is no content between the
<script>
tags (absolutely nothing, not even comments) - The
lang="ts"
part is omitted
I have attempted to change the order of attributes in the <script>
tag (i.e.
<script lang="ts" setup>
), but it results in the same error message in reverse (Expected ">" but found "lang"
)