Cannot find module

I changed the friends.js code:

var friendDb = require('database/friends');

to

var friendDb = require('../database/friends');

And I even tried to explicitly call friendshowfriends.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 is the corresponding application structure:

├── app
│   ├── models
│   │   ├── friends.js
│   │   └── responseGenerator.js

├── database
│   └── friends.json

Bottom comment from Chopper Lee of this post: Unable to find the module in Nodejs , something says about [setting] the system value: NODE_PATH; it should point to your global module location; "

So, I tried this ... and I have a separate entry for a potential problem that I am facing, but I'm not sure if this is 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])

+4
1

:

var friendDb = require('../../database/friends');
+4

Source: https://habr.com/ru/post/1607568/


All Articles