当我尝试使用调试器运行程序时出现以下错误。当我这样做时,程序运行没有任何问题
node app.js
调试器终端出错
Debugging with legacy protocol because Node.js v6.11.0 was detected.
node --debug-brk=21204 --nolazy ca/app.js
Debugger listening on [::]:21204
fs.js:641
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '~/test/users.json'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at Object.<anonymous> (/home/user/test/app.js:2:25)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
app.js和users.json在同一个文件夹中
app.js
var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('users.json', 'utf8'));
console.log(obj);