This is my project structure:
This is index.js
.
var express = require('express');
var router = express.Router();
var fs = require('fs');
var links = require('../models/Links');
var readline = require('linebyline');
var rl = readline('../data.txt');
router.get('/', function (req, res) {
rl.on('line', function (line, lineCount, byteCount) {
var data = line.split(',');
var id = data[0];
var url = data[1];
})
});
module.exports = router;
What am I doing wrong?
I tried rewriting
var rl = readline('/../data.txt');
var rl = readline(__dirname +'/../data.txt');
Nothing works.
ENOENT
is usually permissions. Does your application have the permission to access the file? – Cleekreadline
right beforerl.on('line')
... – Pipes