Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Step back in directories with nodejs path module

How to get this file in fs:

'../dist/index.js'

i tried this:

fs.readFile(path.join(__dirname, '../dist/index.js')

but it's not working.

like image 737
elkebirmed Avatar asked Dec 11 '15 16:12

elkebirmed


2 Answers

Try this:

fs.readFile(path.join(__dirname, '/../dist/index.js'))
like image 53
Rashad Ibrahimov Avatar answered Sep 29 '22 19:09

Rashad Ibrahimov


This will work on all OS

fs.readFile(path.join(__dirname, '..', 'dist', 'index.js'));
like image 27
Hussain Fakhruddin Avatar answered Sep 29 '22 18:09

Hussain Fakhruddin