How to use path module from Node.js to solve file not found issue.

file structure
const path = require('path');
path.join([...paths]path.relative(from, to)
xxxxx@xxxx:~/Project_3/src/test$ node test.js 
/home/aswanth/Moutblue/Project_3/src/server
Which is '../data'
const absolute = path.join(__dirname,'../data')>> /home/aswanth/Moutblue/Project_3/src/data
const relative =path.relative(process.cwd(), absolute)>> ../data

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

App Lab — Part 1

Exclusive — Earth2: New countries released

German Lecture Notes -3 Wortbildung Nomen (Word Formation )

Why I’m betting on React Native for my next Startup

Middleware Functions

Add/Push and Remove Form fields dynamically to FormArray with Reactive Forms in Angular

Augmetic Technology

How to Create a Simple Movie App with Vanilla JavaScript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aswanth KP

Aswanth KP

More from Medium

Deploy NodeJS and ReactJS production code on Windows server

Adventures in Streaming to Http Requests in NodeJS

Application Frameworks

Concise of Node Js