Currently, my packages.json file includes:
"faker": "^5.5.3",
"@types/faker": "^5.5.3",
I am sticking with version 5.5.3 due to another project dependency (codecept) that requires this specific version.
The original faker project available at https://www.npmjs.com/package/faker appears to have been abandoned. It lacks a proper version number and description.
My intention is to switch to the actively maintained project found at https://www.npmjs.com/package/@faker-js/faker
However, when I attempt to:
- Update my packages.json with:
"@faker-js/faker": "^5.5.3"
- Import it using:
(as per faker-js documentation)import { faker } from '@faker-js/faker';
- Invoke it like so:
faker.datatype.number(100);
I encounter the following error:
Cannot read properties of undefined (reading 'datatype')
TypeError: Cannot read properties of undefined (reading 'datatype')
Coincidentally, the same code works on a colleague's laptop.
What could be the issue here? I've tried actions such as deleting the node_modules
directory and starting fresh, as well as running npm install
, but without success.