Error while running typescript node using geo-tz in build file
See original GitHub issueI am using geo-tz in our typescript node application for getting the geolocation details. When i am running the node server locally, it’s working fine but when taken a node server build , i am getting an error like the below while calling geo-tz function like this:
import * as geoTz from 'geo-tz';
const testGeotz= ()=>{
try{
const coords = [110,-20]
let name = geoTz(coords[1], coords[0])[0];
}catch (e) {
console.log(e);
}
}
Why is it happening like this ? My node version - 12.16.3 geo-tz version - 6.0.0
I even tried downgrading the geo-tz version and tried to upgrade to latest v6.0.1 .Still same response. Please tell me whether I have missed out any dependency . @evansiroky @greenkeeperio-bot
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Error while running typescript node using geo-tz in build file
I am using geo-tz in our Typescript Nodejs application for getting the geolocation details. When i am running the node server locally, ...
Read more >Documentation - ECMAScript Modules in Node.js - TypeScript
js has been working to support running ECMAScript modules (ESM). This has been a very difficult feature to support, since the foundation of...
Read more >Error While Running Typescript Node Using Geo-Tz In Build File
The Checker Framework comes with checkers for specific types of errors: 1. Property File Checker to ensure that valid keys are used for...
Read more >ts-loader - npm
To output a built .d.ts file, you can use the DeclarationBundlerPlugin in your webpack config. Failing the build on TypeScript compilation error.
Read more >Getting Started with Executing TypeScript files in ts-node
Learn how to execute TypeScript Javascript files in ts-node but ... Read on and never get stuck in the compile-build-test-feedback loop ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is the issue. node-geo-tz lazy-loads the underlying data by default to attempt to not use so much memory. In whatever build process that is being used, all of the data files must still be able to be referenced as these include the precise data about the timezone boundaries. The reason the error occurs for only certain coordinates is that most coordinates will fall into areas that have the timezones pre-calculated and thus don’t require loading the underlying geographic data to perform an exact lookup near a boundary with the timezones.
I’m going to leave this issue open as I am not sure what the best way to provide guidance is for this use case. The README already states that this package cannot be used in the browser due to loading a lot of data, but it appears that users are trying to build/transpile/whatever on the server-side too. I am not exactly sure what build systems everybody is using and there might be many, but if there is a way to instruct the build process to include every file within the data folder of this project in a way that those files can be required as needed, that should work.
This problem is happening here too.
When I use locally, It works. But, when it is build, that happen.