[英]Failed to load config from \Project\vuejs-frontend\vite.config.js: VueJS
[英]vite failed to load config from vite.config.js,
我通過這樣做創建了一個新的 vue 應用程序(根據 vue 文檔)
npm init vue@latest
npm install
然后我嘗試運行npm run dev
。然后發生了這種情況。
我的環境是這些
我的 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))
}
}
})
我一直在尋找一段時間,但無濟於事。在此先感謝。
最后我找到了解決方案。 問題是因為package.json文件沖突。 Vite is using the wrong package.json file located in the Project's parent directory instead of project's own package.json file.Like this -
所以刪除錯誤的文件,問題就會得到解決。
感謝這個 github 問題答案package.json:1:0: error: Unexpected end of file
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.