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)); ```
CodePudding user response:
if you are using [email protected] 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 [email protected] then its going to work like
npm i [email protected]