danibram / mocker-data-generator

A simplified way to generate masive mock data based on a schema, you can use the awesome fake/random data generators like (FakerJs, ChanceJs, CasualJs and RandExpJs)
https://danibram.github.io/mocker-data-generator/
MIT License
426 stars 45 forks source link

Error when using CommonJS/require: Cannot find module 'tslib' #14

Closed zamnuts closed 7 years ago

zamnuts commented 7 years ago

When using mock-data-generator@2.0.0 in Node.js (v4) with CommonJS paradigm:

var mocker = require('mocker-data-generator').default;

The following error occurs:

module.js:327
    throw err;
    ^

Error: Cannot find module 'tslib'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/myproject/node_modules/mocker-data-generator/build/main/lib/Schema.js:3:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/myproject/node_modules/mocker-data-generator/build/main/lib/Mocker.js:3:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)

Installing tslib as a dependency of my project fixes this issue:

npm install tslib --save

In a production installation of mocker-data-generator, tslib is not installed, but is required in the built ES5 script.

danibram commented 7 years ago

Hi!Thanks for helping and improving this module, this should be fixed in the 2.0.1 build that i just did. Im sorry i was swap tslib from dependencies to devdependencies

danibram commented 7 years ago

I leave open, tell me if it is fixed, i dont know why was not showing in test reports, i tested in node 4...

zamnuts commented 7 years ago

Tested with 2.0.2: tslib is now a dependency of mocker-data-generator and the fix is working. Thanks!