You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vite加载vite.config.js失败求助:Vue项目启动报错

Vite加载配置文件失败:运行npm run dev时出现「vite failed to load config from vite.config.js」错误

我按照Vue官方文档的步骤创建了新的Vue项目:

  1. 执行 npm init vue@latest
  2. 执行 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 04:06:20