Faker.js 混乱

Faker.js Confusion

所以我想用 运行dom 假数据做一些测试,所以我决定得到 faker.js。我为我的项目 运行 yarn add faker 现在我很困惑,因为下载的包似乎与文档 Here 完全不匹配。例如,下载模块中的任何地方都没有 faker.jsfaker.min.js?任何人都可以给我一些指导,说明我在这里缺少什么以及您如何在您的应用程序中实际加载它以使用它吗?或者,如果有另一个好的数据伪造库和更准确的文档,那也很好。谢谢!

编辑:

正如 Faker 的 package.json"main": "index.js" 所遵循的那样。 ./node_modules/faker/index.js

var Faker = require('./lib');
var faker = new Faker({ locales: require('./lib/locales') });
module['exports'] = faker;

因此,faker./node_modules/faker/lib/index.js 上。去那里...在索引文件的开头有一条评论:

this index.js file is used for including the faker library as a CommonJS module, instead of a bundle ...

you can also simply include the "faker.js" file which is the auto-generated bundled version of the faker library

var faker = require(./customAppPath/faker);
var randomName = faker.name.findName();

我不建议使用 Faker 的 build, it seems outdated. The better way to make a bundle by yourself... For example, Faker gives gulp build option 开箱即用。