vite项目中出现的错误

今天在使用vite配置别名时遇到一个错误

error when starting dev server: 
Error: Dynamic require of "path" is not supported

原因在于vite中没有不支持require()

解决方式:

require()改成import xxx from xxx
比如

const path = require('path') // 导致报错

import path from 'path' // 使用import导入解决错误

猜你喜欢

转载自blog.csdn.net/skybulex/article/details/126050033