I want to install all my modules locally so I am installing everything with the "--save-dev" switch which updates the package.json.
I am trying to include this module so I installed using this command:
npm install Faker --save-dev
My app structure is like this:
app controllers models node_modules Faker server.js
So Faker is in the right place but when I add this code in my server.js file:
var faker = require('./Faker');
I get the following error message:
Error: Cannot find module './Faker'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/paulcowan/projects/async-talk/server.js:23:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
But this works:
var Faker = require('./node_modules/Faker');
I did not think that I would have to include the node_modules part.
After a yarn upgrade --latest
I got this error for another reason: A 6.6.6
version has been published 13 days ago and it's totally empty (only one commit called endgame
): https://www.npmjs.com/package/faker.
Is it a hack? Is it a joke? If yes, is it fun? Not sure...
To fix it simply rollback to the last version.
yarn add --dev [email protected]
# or if you use npm
npm install --save-dev [email protected]
Following the answer of akop
below, the safest way seems to switch to faker-js
yarn remove faker
yarn add --dev @faker-js/faker
Then change your imports
import * as faker from 'faker';
// to
import * as faker from '@faker-js/faker';
There is also a type definition for Typescript on their doc but it worked without for me: github.com/faker-js/faker
I spoke with the author of the package who's a fun and crazy guy. He got mad because of an intellectual property theft so he kind of destroyed his open-sourced work.
He now develops a 2000s style virtual desktop for fun buddypond.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With