I'm trying to count the number of lines in a text file using Node.js and set that number to a variable. I found a solution here, but I get this error when trying to use the code.
fs.js:540
binding.open(pathModule._makeLong(path),
^
TypeError: path must be a string
at TypeError (native)
at Object.fs.open (fs.js:540:11)
at ReadStream.open (fs.js:1673:6)
at new ReadStream (fs.js:1660:10)
at Object.fs.createReadStream (fs.js:1608:10)
at Object.<anonymous> (C:\Users\Aidan\Desktop\Javascript\test.js:3:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
To my understanding, this is saying that there is an error with the fs module itself. This couldn't possibly be right. Maybe the enviornment I'm running Node.JS in is not allowing this code to properly execute? I'm running Windows 10 64bit, by the way. A fixed version of this code or an entirely new solution will work. Thank you so much!