Reputation: 15
Ok, this is very simple but I can't seem to figure it out.
I'm currently in (auth -> routes -> users.js) and I want to require a file from a directory in the root (routes -> index.js)
Obviously '...' is not how you do it. The flow of the directories is attached below the code.
//authentication
var express = require('express');
var router = express.Router();
var userdata = require('../controllers/users');
var User = require('../models/users');
//require to lock routes from index.js
require('.../routes/index.js');
Upvotes: 0
Views: 1242
Reputation: 962
If you use just /foo/bar/bing
you'll be using the root of the file system. To go back you use ..
So if you are in Project/auth/routes
and want a file in auth, you'd use ../foo
, the root of the project, ../../bing
.
..
means the parent directory and .
means the current directory. You can chain them together all the way to the file system root.
Upvotes: 0
Reputation: 5973
..
is up one level, so you need to combine two of those with a slash like so: ../../routes/index.js
Upvotes: 1