![](/img/trans.png)
[英]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.