Devendra Verma Devendra Verma - 1 year ago 57
Node.js Question

Accessing files inside the folder, which is inside config folder in sails js(node js framework)

I have to access a file , which is inside a folder which is inside the

). How to access this file from anywhere else like from my controllers or services. How to do this?
I have tried
. But it didn't work. What else I can try?

Answer Source

Let's say you have following directory structure

├── app.js
├── _config
│   ├── _schemas
|       |
|       ├── userSchemas.js
|       ├── otherSchemas.js
├── _controller
│   ├── _module1
|   |   |
|   |   ├── userController.js
|   |   ├── otherController.js
|   ├── otherController.js

In app.js, you may access as


In otherController.js, you may access as


In userController.js, you may access as


Conclude: .. is used to go to parent directory(one directory back) while . is used for current directory

I hope this will help you directory structure in node.js

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download