I want to install all my modules locally, so I install everything with the "-save-dev" switch, which updates package.json.
I am trying to enable this module, so I installed this command:
npm install Faker
My application structure is as follows:
Application model controllers node_modules server.js trickster
So, Faker is in the right place, but when I add this code to the server.js file:
var faker = require('./Faker');
The following error message appears:
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 it works:
var Faker = require('./node_modules/Faker');
I did not think that I would have to include the node_modules part.
source
share