typescript / webpack报错“can only be default-imported using the 'esModuleInterop' flag


原因:This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
解决:

import request = require('request');
//或
import * as request from 'request';

后来在webpack时报错很多modules里文件的这个错:

解决:
在tsconfig.json里添加

"esModuleInterop": true


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM