Node.js 我的index.js正在使用';要求';那么我如何使用';gtfs&x27;使用';导入&x27;
我这里有gtfs.js文件Node.js 我的index.js正在使用';要求';那么我如何使用';gtfs&x27;使用';导入&x27;,node.js,import,require,Node.js,Import,Require,我这里有gtfs.js文件 import { importGtfs, openDb, getRoutes, getTrips, getStoptimes } from 'gtfs'; import { readFile } from 'fs/promises'; const config = JSON.parse(await readFile(new URL('./config.json', import.meta.url))); const db =
import { importGtfs, openDb, getRoutes, getTrips, getStoptimes } from 'gtfs';
import { readFile } from 'fs/promises';
const config = JSON.parse(await readFile(new URL('./config.json', import.meta.url)));
const db = await openDb(config);
let importGtfsData = function () {
importGtfs(config)
.then(() => {
console.log('Import Successful');
})
.catch(err => {
console.error(err);
});
}
app.js在这里
const debug = require('debug')('app:startup')
const config = require('config')
const Joi = require('joi');
const express = require('express');
const logger = require('./middleware/logger')
const courses = require('./routes/courses')
const home = require('./routes/home')
const helmet = require('helmet')
const morgan = require('morgan')
const app = express();
如何同时使用require和import这两种类型?如果我不能,我可以重新构造gtfs.js以使用require,因为这是我所熟悉的