Error: ENOENT: no such file or directory, open '. /file.json'
See original GitHub issueIt cannot seem to find the files which are there. I was able to require the file I needed as js with the same exact path save for the extension. To be sure the issue was not caused by a file path typo I did the following:
echo "{}" > file.json
Then in the importing file in the same directory:
const loadJsonFile = require('load-json-file');
loadJsonFile('./file.json').then(json => {
console.log(json);
//=> {foo: true}
});
which produced the error:
Error: ENOENT: no such file or directory, open '. /file.json'
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
npm - How to resolve Node.js: "Error: ENOENT: no such file or ...
Your app is expecting to find a file at /home/embah/node/nodeapp/config/config.json but that file does not exist (which is what ENOENT ...
Read more >Error: ENOENT: no such file or directory ... - Node-RED Forum
Hello Everyone,. I have recently upgraded by docker image of node-red to 2.1.4. While i deploy the the node-red pod in kubernetes i...
Read more >ENOENT No Such File or Directory Open - YouTube
In This Video We Will See How to Fix npm ERR Code ENOENT npm ERR syscall Open Error or ENOENT No Such File...
Read more >Node.js Error: ENOENT: no such file or directory (2023)
Error : ENOENT: no such file or directory · This problem occurs when a file does not exist; therefore, check to see if...
Read more >no such file or directory, open '/usr/app/package.json' CI error ...
Npm ERR! enoent ENOENT: no such file or directory, open '/usr/app/package.json' CI error but works locally ... Another thing to try would be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you want it relative to the source file,
path.join(__dirname, 'file.json')
Make sure the
process.cwd()
(try logging it) is correct../file.json
is relative from where the Node.js process was started, not where the source file is.