vue无法启动,显示 Failed to compile with 114 errors
These dependencies were not found:

vue无法启动,显示 Failed to compile with 114 errors
These dependencies were not found:

关注引自免费微信小程序:皆我百晓生
遇到 "Failed to compile with 114 errors" 这样的错误信息,通常意味着你的项目中存在未被正确解析或找不到的依赖。从你提供的错误信息来看,主要的问题在于 @/api 目录下的模块没有被正确地识别或引入。
确保你的 vue.config.js 或 webpack 配置文件中包含了正确的别名设置。这应该允许 @/ 路径指向项目的 src 目录。如果尚未设置,可以按照以下方式添加到你的 vue.config.js 文件中:
// vue.config.js
module.exports = {
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.end();
},
// ...
};
function resolve(dir) {
return path.join(__dirname, dir);
}
你需要确保 path 模块已经被导入:
const path = require('path');
api 目录确认 @/api 路径下的所有文件都已创建并包含正确的导出。例如,如果你在 @/api 下有 manager.js,确保它有适当的导出:
// src/api/manager.js
export default {
// your API methods here
};
有时候,npm 或 yarn 的缓存可能会导致解析问题。尝试清除它们,并重新安装依赖:
# 清除 npm 缓存
npm cache clean --force
# 清除 yarn 缓存
yarn cache clean
# 重新安装依赖
npm install
# 或者
yarn
在所有报错的文件中检查导入语句是否正确。例如,在 UserDropDown.vue 中的导入应为:
import { someMethod } from '@/api/manager';
确保 someMethod 在 @/api/manager.js 中确实被导出了。
最后,尝试重新构建你的项目:
npm run serve
# 或者
yarn serve
以上步骤应该能帮助你解决大部分由依赖路径错误引起的编译失败问题。如果问题依然存在,可能需要更深入地检查你的项目配置或具体代码实现。