Vite加载vite.config.js失败求助:Vue项目启动报错
Vite加载配置文件失败:运行
npm run dev时出现「vite failed to load config from vite.config.js」错误 我按照Vue官方文档的步骤创建了新的Vue项目:
- 执行
npm init vue@latest - 执行
npm install
但运行 npm run dev 时,出现了「vite failed to load config from vite.config.js」的错误。
我的环境信息:
- 操作系统:Ubuntu
- Node版本:18.7.0
- npm版本:8.15.0
项目的package.json内容:
{ "name": "vue-project", "version": "0.0.0", "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview --port 4173" }, "dependencies": { "vue": "^3.2.37" }, "devDependencies": { "@vitejs/plugin-vue": "^3.0.1", "vite": "^3.0.4" } }
vite.config.js内容:
import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } } })
我已经搜索了很多相关内容,但还是没找到解决办法,希望有人能帮忙排查问题。
内容的提问来源于stack exchange,提问作者Lwin Moe Hein
相关产品推荐
相关产品推荐

