So I am working on a node js project and I want to load all files from one directory. Everything works on localhost, but when I push it to server, it throws this error:
Error: ENOENT, readdir './maps/'
The error is here (app.js):
var dir='./maps/';
fs.readdir(dir,function(err,files){
if (err) throw err;
files.forEach(function(file){
fs.readFile(dir+file,'utf-8',function(err,data){
if (err) throw err;
//code..
}
});
});
});
I triple checked the directory tree on server and it is indeed the same as on localhost, so I have no idea what's happening here.
The directory tree looks like this (both on server and localhost):
src
app.js
maps
map1.json
map2.json
routes
index.js
and so on...
The server is running on amazon linux.
Aucun commentaire:
Enregistrer un commentaire