-
-
Notifications
You must be signed in to change notification settings - Fork 973
ReferenceError: Intl is not defined #2221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Please provide a minimal reproduction for this issue. Is the given system information your dev system or the actual execution environment? |
Given system information is the actual execution environment |
I was unable to reproduce this with the following system setup: System:
OS: Windows 10 10.0.22621
CPU: (16) x64 Intel(R) Core(TM) i7-7820X CPU @ 3.60GHz
Memory: 55.13 GB / 63.69 GB
Binaries:
Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 8.16.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.1848.0), Chromium (114.0.1823.58)
Internet Explorer: 11.0.22621.1
npmPackages:
@faker-js/faker: 8.0.2 => 8.0.2 With v8.0.2 it works perfectly fine, I only get an error when I actually try to use a method that uses Intl.* p [Error]: This method requires an environment which supports Intl.NumberFormat and Intl.DateTimeFormat In v8.0.1 I cannot run import Faker with the following error message: AFAICT Node has Intl support for many major versions, so it surprises me that it is missing for you. I simplified your reproduction to this: import type { Faker } from "@faker-js/faker";
delete Intl.DateTimeFormat;
delete Intl.NumberFormat;
Intl = undefined;
const { faker } = (await import("@faker-js/faker")) as { faker: Faker };
// const { faker } = require("@faker-js/faker") as { faker: Faker };
const request = {
userName: faker.internet.userName(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
email: faker.internet.email(),
};
console.log(request); And was unable to reproduce the error, please provide a working reproduction for this issue. |
Or do we have wrap that in a try catch? (Because @hellotatia Can you try to call I would still like to have a way to reproduce the error, so we can actually test, that that fixes the error. |
i increasingly think the costs of working round Intl bugs in various niche environment outweighs the benefits it brings. Accordingly i tried implementing commitDate in with vanilla JS + formatting functions in #2222 |
As a workaround you need an Intl-polyfil. Even if it is an empty one. globalThis.Intl = undefined; Sorry, that the first workaround only worked for environments where Intl is available.
The try-catch was for our own/internal code. But we will remove the usage of Intl in the next version (released probably in July). |
If this works, why not just literally doing |
Pre-Checks
Describe the bug
Hello, I'm trying to use Faker extension and when I run the test, I get the error message on the console:
Minimal reproduction code
No response
Additional Context
package.json devDependencies:
import:
import { faker } from '@faker-js/faker';
Environment Info
Which module system do you use?
Used Package Manager
npm
The text was updated successfully, but these errors were encountered: