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

Type error: moment.locale is not a function #124

Closed armandolezama closed 1 year ago

armandolezama commented 1 year ago

Hi, when I install and import mocker, the next error is thrown:

Uncaught TypeError: moment.locale is not a function at node_modules/casual-browserify/src/providers/ar_SY/date.js (date.js:2:8) at __require2 (chunk-S5KM4IGW.js?v=05871a14:18:50) at node_modules/casual-browserify/src/casual_browserify.js (casual_browserify.js:21:16) at __require2 (chunk-S5KM4IGW.js?v=05871a14:18:50) at Generator.ts:6:11

This error appears in my browser after I serve my aplication. This happens when mocker is imported with the next line:

import mocker from 'mocker-data-generator';

I'm using vite and react, and these are my dependencies (package.json example):

{ "type": "module", "scripts": { "dev": "vite", "build": "vite build", "preview": "vite preview" }, "dependencies": { "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@fontsource/public-sans": "^4.5.11", "@fontsource/roboto": "^4.5.8", "@mui/icons-material": "^5.10.14", "@mui/joy": "^5.0.0-alpha.56", "@mui/material": "^5.10.14", "@mui/x-data-grid": "^5.17.13", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.4.3" }, "devDependencies": { "@types/react": "^18.0.24", "@types/react-dom": "^18.0.8", "@vitejs/plugin-react": "^2.2.0", "mocker-data-generator": "^2.12.0", "vite": "^3.2.3", "vite-plugin-pwa": "^0.13.3" } }

I tried to install moment and casual-browserify but the result is the same

danibram commented 1 year ago

Good night! I just release a new version that remove all specific generators from the package so you shouldnt have this kind of error again. That is a breaking change and also schemas and generation must be updated, just in case =)