Getting "Intl is not defined" in Dataform GCP project

110 views Asked by At

I'm working on a project in Dataform in the Google Cloud Plataform. I want to use an external package called luxon to deal with some DateTime requirements in my project. The code below is where I'm working with luxon:

const { DateTime } = require('luxon')


const TABLE_SHARDING_YESTERDAY_SUFFIX = DateTime.utc().minus({ days: 1 }).toFormat('yyyyMMdd')

module.exports = {
  TABLE_SHARDING_YESTERDAY_SUFFIX
}

And when I try to compile my project, I get this error:

Intl is not defined

I searched about it, and I understood that the Intl is a built-in object correspond to the ECMAScript Internationalization API (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) and, by the error above, it is not available.

Is there any solution to fix that problem?

1

There are 1 answers

2
Denis Kiryanov On

As far as I know, Node.js had some problems with i18n support. There is a disussion on that topic on Github. Also they clarified that there are some subtleties with ECMAScript standards support:

ECMAScript 5.1 is defined by standard ECMA-262 edition 5.1, while the ECMAScript Internationalization API is defined by a separate complementary standard, ECMA-402

It means that Node.js runtime can implement ECMA-262 edition 5.1 and thus ECMAScript 5.1 without implementing ECMA-402.

Can you update your Node.js version? Looks like it could help to solve the issue since all locales are now included as of Node.js v13.

Also please note the issue DateTime.fromFormat fails in some cases when running Node 18.13.0 which is is caused by an update to ICU in Node.js.

Node.js versions 18.13+ should support it.