相关推荐recommended
vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘
作者:mmseoamin日期:2024-04-27

运行vite+vue3项目时报错:

failed to load config from …/vite.config.ts

error when starting dev server:

Error: Cannot find module ‘node:path’

Require stack:

/Users/list/Downloads/Admin-master/node_modules/vite/dist/node-cjs/publicUtils.cjs

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第1张

百度了发现是node版本不够,于是去升级node到16版本

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第2张

1.清除npm缓存:

npm cache clean -f

2.安装node版本管理工具n:

npm install n -g 或 sudo npm install n -g

3.查看所有node版本:

npm view node versions

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第3张

4.指定安装版本:

n 16.0.0

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第4张

这里提示not found 是因为在安装管理工具时没有权限,需要在命令的前面加上sudo,如sudo n 16.0.0,然后出现以下就是安装正确

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第5张

5.也可以升级到最新的稳定版本:

sudo n stable

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第6张

然后去启动项目:npm run dev 启动成功

vite+vue3运行项目报错failed to load config from ..vite.config.tsCannot find module ‘node:path‘,在这里插入图片描述,第7张