2021年2月2日星期二

I tried requiring nodejs fs module and keep getting the error below, how do I go about it please?

code line below

var fs= require('fs');   var readMe = fs.readFileSync('readMe.txt', 'utf-8');     // method to read file in node..note the  'sync' maintains strict order of code  console.log('readMe.txt');  

when I run I get this

C:\visual studio code\nodeJS>node "c:\visual studio code\nodeJS\netNinja\app.js"internal/fs/utils.js:308      throw err;      ^    Error: ENOENT: no such file or directory, open 'readMe.txt'  ?[90m    at Object.openSync (fs.js:476:3)?[39m  ?[90m    at Object.readFileSync (fs.js:377:35)?[39m      at Object.<anonymous> (c:\visual studio code\nodeJS\netNinja\app.js:105:20)  ?[90m    at Module._compile (internal/modules/cjs/loader.js:1063:30)?[39m  ?[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)?[39m  ?[90m    at Module.load (internal/modules/cjs/loader.js:928:32)?[39m  ?[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)?[39m  ?[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)?[39m  ?[90m    at internal/main/run_main_module.js:17:47?[39m {    errno: ?[33m-4058?[39m,    syscall: ?[32m'open'?[39m,    code: ?[32m'ENOENT'?[39m,    path: ?[32m'readMe.txt'?[39m  }  

I am very sorry if the questions construction is not so good, this is my first time on stack overflow kindly bear with me and I'll really appreciate the response

https://stackoverflow.com/questions/66020485/i-tried-requiring-nodejs-fs-module-and-keep-getting-the-error-below-how-do-i-go February 03, 2021 at 10:40AM

没有评论:

发表评论