1. 問題現(xiàn)象
vite項目中出現(xiàn)的錯誤Error: Dynamic require of “path” is not supported
2. 為什么會這樣?
因為vite中沒有不支持require()
文章來源:http://www.zghlxwxcb.cn/news/detail-812739.html
3. 如何解決
將require()
改成import xxx
文章來源地址http://www.zghlxwxcb.cn/news/detail-812739.html
const path = require('path') // 之前:導致報錯
import path from 'path' // 現(xiàn)在:使用import導入解決錯誤
到了這里,關于vite配置別名時遇到錯誤Error: Dynamic require of “path“ is not supported的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!