解决typescrip使用xml2js库报错:Module not found: Error: Can‘t resolve ‘timer‘ in ‘‘
1.xml2js使用方法:
yarn add xml2js
yarn add @types/xml2js --dev
2.引入
var parseString = require('xml2js').parseString;
var xml = "<root>Hello xml2js!</root>"
parseString(xml, function (err:any, result:any) {console.dir(result);
});
3.下面报错的解决
ERROR in ./node_modules/xml2js/lib/parser.js 35:17-47
Module not found: Error: Can't resolve 'timers' in 'E:\react\digital-standard\node_modules\xml2js\lib'BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:- add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'- install 'timers-browserify'
Failed to compile.
执行
npm install --save stream timers
4.关于@type
typescript是js的超集,功能比js更丰富。写代码的时免不了引入第三方库但是现在的大部分库还是用js写的,在ts中直接引入js库会报错。解决问题一般有两个1.用ts重写所有js库,这个方法最可靠但实现起来基本不可能2.为js库添加ts类型,这就是ts的解决方案,安装某个第三方库时还要执行npm install @types/xxx以便把类型文件也安装。@types文件下存放的就是引入js库的类型定义文件,一般地@types文件夹下与某个库名一样,内部有一个index.d.ts文件,这个文件就是某个js库的类型定义文件
解决typescrip使用xml2js库报错:Module not found: Error: Can‘t resolve ‘timer‘ in ‘‘相关推荐
- webpack4 报错 Module not found: Error: Can't resolve
webpack 要打包的文件的路径 -o 打包好的输出文件的路径 报错 Module not found: Error: Can't resolve... 查到的解决方法通常是说 文件路径大小写写错了 ...
- 前端报错Module not found: Error: Can‘t resolve巴拉巴拉的
我用的anrd pro框架的ts版,搞路由时有了这个报错,如果你无论怎么改路由配置她都报这个错,那么这个错还有一种可能就是你写出来了这个路由但是从来没有引用过他,随便这个地方用一下看看是不是报错就消失 ...
- Vue报错Module not found: Error: Can‘t resolve ‘less-loader‘
方法一 npm install less less-loader --save-dev 方法二
- 报错Module not found: Error: Can't resolve './public/javascript/page/index/index.js' in 'E:\pr
描述:出现这种错误的原因是找不到该文件.
- Vue项目启动webpack报错Module build failed: Error: No PostCSS Config found in......
自己写的公司项目,今天需要提交到公司版本库,可是在本地启动正常的项目,拷贝到git文件目录下突然报错Module build failed: Error: No PostCSS Config foun ...
- npm 报错 Module build failed: Error: No PostCSS Config found in:
npm 报错 Module build failed: Error: No PostCSS Config found in: 你在网上找的解决方案应该有提到webpack版本的问题.不要以为升级web ...
- Vue报错Module build failed Error Node Sass version 6.0.1 is incompatible with ^4.0.0.解决方案
Vue报错Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.解决方案 错误提示: ERRO ...
- 安装python37路径报错_解决pycharm安装python库报错问题
最近在玩微信图灵机器人,不过我安装有一些库,安装报错,上网找了很久,总结有两种方法,记录一下 方法一: 手动安装,直接到官网你需要的python库下载到本地, 放在安装python路径,C:\User ...
- npm 报错 Module build failed: Error: No PostCSS Config found in
问题描述: 项目在本地运行不报错,上传到 GitHub 之后,再 clone 到本地,执行: npm install 或 cnpm install 安装完成之后再执行: npm run dev 这时 ...
最新文章
- python 传感器数据结构_Python常用的数据结构详解
- c语言获取当前日期和时间
- python田字格的输出的两种方法
- dede如何做SEO,一起探讨下
- java的前生今世_HBaseGC的前生今世-身世篇
- Ubuntu Linux系统下搭建自己的Web服务器
- 就业技术书文件表格_429页标准指南,教你如何管理工程监理文件资料,丰富图表一看就会...
- mysql调优explain_MySql性能调优利器之Explain
- 杭电1710 (已知二叉树前中序 求后序)
- C语言的很吊的printf-----来自一个C语言竞赛题目
- DirectAdmin安装mod_encoding支持中文
- python实训报告5000字_20193420 实验一 《Python程序设计》实验一报告
- 控制文件丢失的恢复(续)
- 史上最全的 struts2 面试题
- 毕业论文每周报告进度计算机,计算机毕业论文进度安排怎么写
- html 怎么转换,html格式怎么转换
- C# 谷歌邮箱发送邮件
- .net mvc笔记3_Understanding Razor Syntax
- vlookup使用步骤_VLOOKUP函数的使用方法详解
- 邓宁-克鲁格效应(Dunning-Kruger effect,达克效应)