I'm currently trying to import Faker into my project.
I have a file similar to the following:
import * as faker from 'faker';
interface Test {
FirstName: String,
LastName: String
}
function create() {
let account: Test = {
FirstName: faker.name.firstName(),
LastName: faker.name.lastName()
}
}
When I run this, I get an error: SyntaxError: Cannot use import statement outside a module
I'm importing this in another file without any issues, but the moment Faker is attempted to be imported I receive this error. I've tried a handful of solutions that should fix this, such as modifying the tsconfig and package.json to add type: modules or change the lib and target in the tsconfig but no luck.
I should note this works with hardcoded values, but I need to use faker.
Edit: Just mentioning I have tried const/var faker = require('faker'); as well as import faker = require('faker')