Uncaught ReferenceError: __VUE_HMR_RUNTIME__ is not defined

感谢上Di_123 2020-12-24 03:18:14
这个问题应该如何解决呀?
本人用@vue/cli4.5.9搭建的一个SPA(single page application),vue2,环境搭建好之后,在vue.config.js的配置如下:

const CompressionWebpackPlugin = require('compression-webpack-plugin')
const path = require('path');
const proxyUrl = 'https://www.baidu.com/'//访问接口对应的域名

function resolve(dir) {
return path.join(__dirname, dir)
}

module.exports = {
devServer: {
port: 8080,
progress: true,
open: true,
host: '0.0.0.0',
hotOnly: false,
// 设置反向代理
proxy: {
'/api': {
target: proxyUrl,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
'/login': {
target: proxyUrl,
changeOrigin: true,
pathRewrite: {
'^/login': ''
}
},
},
},
lintOnSave: 'warning',
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 生产环境
config.plugins.push(
new CompressionWebpackPlugin({
// asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
)
}
if (process.env.NODE_ENV === 'development') {
config.devtool = 'eval-source-map'
}
},
chainWebpack:(config) => {
//set第一个参数:设置的别名,第二个参数:设置的路径
config.resolve.alias
.set('@', resolve('./src'))
.set('@assets', resolve('.src/assets'))
.set('@components', resolve('./src/components'))
.set('@pages', resolve('./src/pages'))
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'scss',
injector: 'append',
patterns: [path.resolve(__dirname, './src/styles/util.scss')]
}
}
}



然后在终端执行命令:npm run serve去启动项目,就会报错,导致整个页面都白屏,无法访问,真是醉了,这个应该怎么解决呀?让我很懵呀!错误如下:

Uncaught ReferenceError: __VUE_HMR_RUNTIME__ is not defined
...全文
13343 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级码丽. 2023-01-29
  • 打赏
  • 举报
回复

真恶心

img

  • 打赏
  • 举报
回复

大佬解决了么,我也遇到了。。

Li_qiongqiong 2021-09-27
  • 举报
回复
@网络上人称代码说唱的陈八一 解决了嘛?我也遇到了
定个小目标 2022-02-24
  • 举报
回复
@Li_qiongqiong 怎么解决的?
zhoupeihuang 2021-06-17
  • 打赏
  • 举报
回复

解决办法

一开始以为是node版本过高导致,后面我分别切换了11、12、13、14、15的版本,均无效果。根据我折腾了两天的经验,应该是vue-cli版本过高导致的,将vue-cli4降级至vue-cli3就没有出现过这个问题了。如何降级请自行百度。

感谢上Di_123 2020-12-28
  • 打赏
  • 举报
回复
WARNING Compiled with 9 warnings 18:27:13 warning in ./src/App.vue?vue&type=template&id=7ba5bd90 "export 'createBlock' (imported as '_createBlock') was not found in 'vue' warning in ./src/pages/login/index.vue?vue&type=template&id=247e7dd8&scoped=true "export 'createTextVNode' (imported as '_createTextVNode') was not found in 'vue' warning in ./src/App.vue?vue&type=template&id=7ba5bd90 "export 'createVNode' (imported as '_createVNode') was not found in 'vue' warning in ./src/App.vue?vue&type=template&id=7ba5bd90 "export 'openBlock' (imported as '_openBlock') was not found in 'vue' warning in ./src/pages/login/index.vue?vue&type=template&id=247e7dd8&scoped=true "export 'popScopeId' (imported as '_popScopeId') was not found in 'vue' warning in ./src/pages/login/index.vue?vue&type=template&id=247e7dd8&scoped=true "export 'pushScopeId' (imported as '_pushScopeId') was not found in 'vue' warning in ./src/App.vue?vue&type=template&id=7ba5bd90 "export 'resolveComponent' (imported as '_resolveComponent') was not found in 'vue' warning in ./src/pages/login/index.vue?vue&type=template&id=247e7dd8&scoped=true "export 'toDisplayString' (imported as '_toDisplayString') was not found in 'vue' warning in ./src/pages/login/index.vue?vue&type=template&id=247e7dd8&scoped=true "export 'withScopeId' (imported as '_withScopeId') was not found in 'vue' 终端也会有这些警告,让我不知道应该怎么解决,真是醉了!
感谢上Di_123 2020-12-28
  • 打赏
  • 举报
回复
node版本:11.15.0,我尝试着把node版本切换到12版本,不行,失败了
亦夜 2020-12-25
  • 打赏
  • 举报
回复
node版本多少

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧