question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while running typescript node using geo-tz in build file

See original GitHub issue

I 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);
           }
}

image

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:open
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
evansirokycommented, Nov 24, 2020

We are using nx workspace for running the app and building it . Building will transpile typeScript file into JavaScript (under the hood, its what tsc does)…

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.

1reaction
miguelpfitschercommented, Nov 23, 2020

This problem is happening here too.

When I use locally, It works. But, when it is build, that happen.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found