基于ts的node项目引入报错归纳

一、导入类型定义文件错误

node_modules/@types/leaflet/index.d.ts:128:1
    128 export = e;
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

这个错误表明使用 export = 语法,但 TypeScript 配置中没有启用 esModuleInterop 标志。
这个错误通常出现在导入类型定义文件时,特别是在使用 CommonJS 的情况下。
解决办法

 "compilerOptions": {
    "esModuleInterop":true
  }

二、TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

解决办法

{
  "compilerOptions": {
    "module": "ESNext" // or ES2015, ES2020
  },
  "ts-node": {
    "esm": true
  }
}
posted @   槑孒  阅读(405)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
历史上的今天:
2022-03-13 javascript 判断是上午还是下午 还是晚上
2022-03-13 微信小程序实现一行滑动显示很多文字--scroll-view
2022-03-13 小程序 | 数据异步缓存处理
2022-03-13 小程序时间格式大全
2022-03-13 ColorUI | TabBar分页组件页面内容搭建
2022-03-13 ColorUI | TabBar搬运
点击右上角即可分享
微信分享提示