Reputation: 153
I've changed my friends.js code from:
var friendDb = require('database/friends');
to
var friendDb = require('../database/friends');
And I've even tried explicitly calling friends
as friends.json
But no matter what I do, I have no friends...
Error: Cannot find module '../database/friends'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/seanwilliamson/Desktop/streamcolor-v2.0/app/models/friends.js:2:16)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
In all seriousness, here's the relevant app structure:
├── app
│ ├── models
│ │ ├── friends.js
│ │ └── responseGenerator.js
├── database
│ └── friends.json
The bottom comment from Chopper Lee of this stack post: Cannot find module in Nodejs mentioned something about "[setting] the system value : NODE_PATH; it should point to your global module location;"
So I tried that... and I have a whole separate post for the potential problem I'm having there but I'm not sure if it's related: echo $NODE_PATH returns two global installation paths (basically, I think I have two installation paths for my global modules whenever I run npm install -g [foo-module]
)
Upvotes: 4
Views: 2418
Reputation: 11677
It should be:
var friendDb = require('../../database/friends');
Upvotes: 4