Module not found: Error: Can't resolve
时间: 2023-09-26 13:10:05 浏览: 270
module-resolve:尝试在不抛出错误的情况下找到已安装的模块
Module not found: Error: Can't resolve是一个常见的报错,表示在编译过程中找不到模块。解决这个问题有几种方法。首先,你可以尝试删除项目文件夹下的node_modules文件夹,并执行npm install命令重新安装包。这通常可以解决一些依赖问题。\[1\]
另外,你还可以尝试安装polyfill-webpack-plugin中的http和stream-http模块,并在vue.config.js中进行相应的配置修改。具体的配置可以参考以下代码:
```javascript
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
publicPath: "./",
configureWebpack() {
return {
resolve: {
fallback: {
http: require.resolve("stream-http"),
},
},
}
},
})
```
然后,重新运行项目,执行npm run serve命令,看看问题是否解决了。\[2\]
希望这些解决方案能够帮助你解决Module not found: Error: Can't resolve的问题。如果还有其他疑问,请随时提问。
#### 引用[.reference_title]
- *1* [一招解决vue中Module not found Error Can‘t resolve ‘xxx](https://blog.csdn.net/m0_67391683/article/details/123375049)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Module not found: Error: Can‘t resolve ‘http‘ in( 百分百有效 )](https://blog.csdn.net/qq_29820687/article/details/125869822)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文