-1

In angular project I am creating two files to generate fake data.

File structure as below https://i.stack.imgur.com/UBSFQ.png

Writing generate.js to create data into database.json

And creating command in package.json as below. https://i.stack.imgur.com/hIj6t.png

But am getting errors while running code as "npm run generate" https://i.stack.imgur.com/70c2M.png

FYI : I tried deleting node modules and regerating them but not able to get solution


var database = { products: []};

for (var i = 1; i<= 300; i++) {
  database.products.push({
    id: i,
    name: faker.commerce.productName(),
    description: faker.lorem.sentences(),
    price: faker.commerce.price(),
    imageUrl: "https://source.unsplash.com/1600x900/?product",
    quantity: faker.random.number()
  });
}

console.log(JSON.stringify(database)); ```
Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Trupti
  • 1
  • 2
  • Please add code and data as text ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](//meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. – gre_gor Feb 12 '22 at 06:37
  • @gre_gor Sure, Got it. Thanks will count this now on – Trupti Feb 14 '22 at 05:35

1 Answers1

3

if you are using faker@6.6.6 latest version then it's not going to be work because developer closed this project with last commit of endgame but if you want to use fakerjs then downgrade your package by faker@5.5.3 then its going to work like

npm i faker@5.5.3
Anshu Meena
  • 169
  • 1
  • 6