Dynamic require of "path" is not supported
时间: 2023-12-16 22:05:53 浏览: 239
jQuery is not defined 错误原因与解决方法小结
5星 · 资源好评率100%
问题中提到的错误"Dynamic require of "path" is not supported"是在使用vite配置别名时遇到的。这个错误的原因在于vite不支持使用require()进行动态导入。解决这个错误的方式是将require()改成import导入的方式。比如,将原来的const path = require('path')改成import path from 'path'。这样可以使用import语法来解决这个错误。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [vite项目中出现的错误](https://blog.csdn.net/skybulex/article/details/126050033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [自定义别名报错Dynamic require of “path“ is not supported](https://blog.csdn.net/qq_44848480/article/details/129702336)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文