Работа с «узлом-геокодером» в машинописном тексте

#node.js #typescript

Вопрос:

Я пытался скомпилировать свой код с помощью cmd, используя tsc -w api.ts

 import NodeGeocoder from 'node-geocoder'; import * as geolib from 'geolib'; var lat1 = 33.234567; var lon1 = -118.235691;  var geocoder = NodeGeocoder({  provider: 'opencage',  apiKey: 'b665015568af43d78d9e02d52d88f1f8' }); const findDistance = (async (address : string) =gt;{   var result = await geocoder.geocode (address);  var lat2 = result[0].latitude;  var lon2 = result[0].longitude;  console.log(lat2, lon2);  if (lat2 !== undefined amp;amp; lon2!==undefined){  var dist = geolib.getDistance(  { latitude: lat1.toFixed(4), longitude : lon1.toFixed(4) },  { latitude: lat2.toFixed(4) , longitude: lon2.toFixed(4) }  );  console.log(dist);  } });  findDistance("Long Beach, California");  

Но я получаю эту ошибку в первой строке. api.ts:1:8 error TS1259: Module '"C:/Projects/opencage-api/node_modules/@types/node-geocoder/index"' 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.

Вот как выглядит мой файл tsconfig.json:

 "compilerOptions": {  "module": "commonjs",  "target": "ES2017",  "esModuleInterop": true  },  "compileOnSave": false, }  

Я следил за различными потоками и вносил изменения в tsconfig.json, но до сих пор ничего не работало.

 "devDependencies": {  "@types/node-geocoder": "^3.24.3",  "node-geocoder": "^3.27.0"  }