Use some thing like this var db = require('../model/db');
It basically means ../
moving one step up from the current directory then into model and then to db.
You need to use this to move up the directory structure and then use that in require .
node.js is a server-side Javascript execution environment that
combines the V8 Javascript engine with a bunch of server-side
libraries. require() is one such feature that node.js adds to the
environment. So, when you run node in the terminal, you are running an
environment that contains require().
require() is not a feature that is built into the browser. That is a
specific feature of node.js, not of a browser. So, when you try to
have the browser run your script, it does not have require().
In order to use Require Js . Just follow this link