问题描述
拥有一个 Typescript Express 服务器,用于使用 GTFS 库 (https://github.com/BlinkTagInc/node-gtfs) 使用 GTFS 数据
- 版本(“gtfs”:“^3.0.4”)
以这种方式导入库
import { importGtfs } from 'gtfs';
require() of ES modules is not supported.
require() of <Project-path>/node_modules/gtfs/index.js from <Project-path>/src/index.ts is an ES module file as it is a .js file whose nearest parent package.
json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs,change the requiring code to use import(),or remove "type": "module" from <Project-path>/node_modules/gtfs/package.json.
以这种方式使用它
import { importGtfs } from 'gtfs';
为 GTFS 找到了一个类型库 https://www.npmjs.com/package/gtfs-types 但是找不到在项目中包含这些类型的解决方案