Answer the question
In order to leave comments, you need to log in
Why can't I import the faker module?
I'm writing TypeScript code, I need random data, so I decided to use the Faker package
Installed it like this:
npm i --save-dev @types/faker
This is how I import it into my project:
But the following error pops up in the console:
Answer the question
In order to leave comments, you need to log in
In order for packages to be loaded from node_modules by name, the script must be run in node (i.e. on the server), or collected by a collector (which will pick it up by name and pack it into a script).
If you want to use them directly in the browser via type moule, you will have to explicitly specify specific paths to specific script files with your hands. package.json
and everything connected with it is the node ecosystem. Because of its convenience and versatility, it is accepted as the standard for all front development, but the browser knows nothing about it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question