![](/img/trans.png)
[英]TypeScript Integration with existing Node js express project
[英]Typescript Support for JS Library (node-gtf) in a Express Project
有一個 Typescript Express Server,用於使用 GTFS 庫( https://github.com/BlinkTagInc/node-gtfs )使用 GTFS 數據
以這種方式導入庫
import { importGtfs } from 'gtfs';
但由於沒有 TS 支持,我面臨這個錯誤
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找到了一個類型庫但無法找到將這些類型包含在項目中的解決方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.