# 1. 清理旧依赖 Windows命令
rmdir /s /q node_modules
del package-lock.json
# 2. 重新安装依赖
npm install
# 3. 启动项目
npm run serve
1. 清除缓存并重新安装依赖
# 清除 npm/yarn 缓存
npm cache clean --force
# 或
yarn cache clean
# 删除 node_modules 和 lock 文件 linux命令
rm -rf node_modules
rm package-lock.json # 或 yarn.lock
# 重新安装依赖
npm install
# 或
yarn install
确认缓存清理是否成功
# 查看缓存目录位置(Windows 示例)
npm config get cache
# 典型路径:C:\Users\你的用户名\AppData\Roaming\npm-cache
# 手动删除缓存(更彻底)
rmdir /s /q "D:\program\nvm\node_cache"
强制安装指定 npm 版本
# 使用精确版本号安装(避免自动选择不兼容版本)
npm install -g npm@6.14.18 --registry=https://registry.npm.taobao.org
# 验证安装
npm -v # 应该显示 6.14.18