vue ssr error: TypeError: Cannot read property 'replace' of undefined
在开发vue ssr应用时, yarn build yarn start 之后启动正常:
info Server running at: http://0.0.0.0:6606
在访问页面时,发现页面降级到SPA,服务端报错:
debug Server rendering encountered an error: { TypeError: Cannot read property 'replace' of undefined }
经过排查,错误出在 vue-server-renderer(v2.6.11) 中:
9081 TemplateRenderer.prototype.getUsedAsyncFiles = function getUsedAsyncFiles (context) {
9082 if (!context._mappedFiles && context._registeredComponents && this.mapFiles) {
9083 var registered = Array.from(context._registeredComponents);
9084 context._mappedFiles = this.mapFiles(registered).map(normalizeFile);
9085 }
9086 return context._mappedFiles
9087 };
原因是 this.mapFiles(registered) 中没有匹配到css的sourcemap文件
修改源码过滤掉 undefined 可以解决报错(错误示范)
可以修改 vue.config.js 配置文件(项目由vue cli3/4创建):
module.exports = {
+ css: {
+ extract: true,
+ sourceMap: true
+ }
};
为css启用sourcemap就行了,问题解决。记得重新build
vue ssr error: TypeError: Cannot read property 'replace' of undefined的更多相关文章
- underscore.js定义模板遇到问题:Uncaught TypeError: Cannot read property 'replace' of undefined
代码正确缩进位置如下, extend "layout" block 'content',-> div ->'nihao' script id:"Invoice ...
- vue报错TypeError: Cannot read property 'protocol' of undefined
错误信息如下所示: isURLSameOrigin.js?3934:57 Uncaught (in promise) TypeError: Cannot read property 'protocol ...
- Appium dmg 安装:[TypeError: Cannot read property 'replace' of undefined]
问题原因:appium dmg 版本没有默认node.js 解决方案:安装稳定版的node.js.(官网下载安装即可.) 验证:命令行输入:node -v 查看版本号 npm -v 查看版本号
- vue报错TypeError: Cannot read property '$createElement' of undefined
报错截图: 这个错误就是路由上的component写成了components
- ngzorro draw 第一次打开 ERROR TypeError: Cannot read property 'overlayElement' of undefined
at NzDrawerComponent.push../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd.js.NzDrawerComponent.trap ...
- TypeError: Cannot read property 'compilation' of undefined
Vue build失败 TypeError: Cannot read property 'compilation' of undefined 1. 使用npm run build 失败 使用npm ...
- Vue使用Typescript开发编译时提示“ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'afterCompile' of undefined”的解决方法
使用Typescript开发Vue,一切准备就绪.但npm start 时,提示“ ERROR in ./src/main.tsModule build failed: TypeError: Cann ...
- [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined、vuejs路由使用的问题Error in render function
1.[Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined 注意,只要出现Error i ...
- SharePoint 2013 Error - TypeError: Unable to get property 'replace' of undefined or null reference
错误信息 TypeError: Unable to get property ‘replace’ of undefined or null referenceTypeError: Unable to ...
- vue v-if:"TypeError: Cannot read property 'length' of undefined"
在使用v-if判断一个数组大小为0时,会出现 length 是undefined的错误:[Vue warn]: Error in render: "TypeError: Cannot rea ...
随机推荐
- SQL Server – Transaction & Isolation 事务与隔离
前言 上回在谈到 Concurrency 并发控制 时, 有提到过事务的概念. 这篇就补上它具体的实现. 以前写过相关的文章: sql server 学习笔记 (nested transaction ...
- SQL Server Temporary Table & Table Variable (临时表和表变量)
参考: 在数据库中临时表什么时候会被清除呢 Temporary Tables And Table Variables In SQL 基本常识 1. 局部临时表(#开头)只对当前连接有效,当前连接断开时 ...
- 【赵渝强老师】在MongoDB中使用MapReduce方式计算聚合
MapReduce 能够计算非常复杂的聚合逻辑,非常灵活,但是,MapReduce非常慢,不应该用于实时的数据分析中.MapReduce能够在多台Server上并行执行,每台Server只负责完成一部 ...
- uniapp中前端canvas合成图片使用详解
项目开发中用到了定位打卡,保存当前位置到上传图片的功能.刚开始想着后端人员合成,前端上传经纬度.位置信息和图片就OK,没想到后端人员以使用项目中现有的组件为借口,让前端合成图片,造成前端工作量大增,再 ...
- dotnet Core 静态方法和构造方法
// 静态方法: // 特点:1.生命周期一旦创建-应用结束 才会结束 2.全局的 3.效率高(放在内存中) // 用户:用户登录,系统配置信息,系统设置,SQLHelper // 注意:静态的东西创 ...
- 09-react的组件传值 props
// 组件传值 props 接收传递过来的数据 import ReactDom from "react-dom" import { Component } from "r ...
- element-admin - 图片上传组件 ImageUpload
预览详情 : 父组件:注册引入子组件 :只需要传递一个数据 limit :这是限制显示多少张图片 : 子组件: - 图片上传 - el-upload 代码 : <template> & ...
- 斜率优化DP简单总结&&“土地购买”题解
今天刚刷完了斜率优化DP,简单从头回顾一下. \[首先,能写出DP方程应该是最重要的,毕竟斜率只是用来优化的 \] 那么一个DP方程能用斜率优化,具备一种形式: \[f[i]+s1[i]+A[i]*B ...
- 云原生周刊:6 项 K8s 成本控制策略 | 2023.7.17
开源项目推荐 Base Image Finder 当使用容器扫描工具来识别已知漏洞(CVE,或常见漏洞和暴露)时,可能很难理解漏洞在容器中的位置,以及如何缓解这些漏洞.通常,最简单.最有效的缓解方法是 ...
- Redhat7重置root管理员密码
如果要重置Red Hat Enterprise Linux Server release 7.0 的root常见有2种办法(均测试有效) rd.break方法 1.重启Linux系统主机并出现引导界面 ...