Error: ENOENT: no such file or directory
Closed this issue · 1 comments
pavinduLakshan commented
I'm trying to translate an English subtitle file on Windows 10 machine, The code I tried is as follows. The subtitle file is in the same directory as the nde.js script.
const { translate } = require("@ipmanlk/sinhala-sub-maker")
translate("subtitles-en.srt").then(siSub => {
//you can directly write siSub to a .srt file using fs
console.log(siSub);
});
However, I'm getting the following error.
(node:15132) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'subtitles-en.srt'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at F:\heladhi\New folder\node_modules\@ipmanlk\sinhala-sub-maker\lib\submaker.js:8:24
at new Promise (<anonymous>)
at translate (F:\heladhi\New folder\node_modules\@ipmanlk\sinhala-sub-maker\lib\submaker.js:6:12)
at Object.<anonymous> (F:\heladhi\New folder\index.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15132) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error
originated either by throwing inside of an async function without a catch block, or by
rejecting a promise which was not handled with .catch(). To terminate the node process
on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:15132) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I tried different path formats such as ./subtitles-en.srt
and even the full path F:\heladhi\New folder\subtitles-en.srt
, but had no luck so far.
My project directory structure:
pavinduLakshan commented
Okay the problem was the file extension. I have used .srt
instead of .vtt
😄