Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casamia918/031199ff5e015c56f87088765b047526 to your computer and use it in GitHub Desktop.
Save casamia918/031199ff5e015c56f87088765b047526 to your computer and use it in GitHub Desktop.
node.js) ENOENT, no such file or directory when using fs.createWriteStream

If you are facing the "ENOENT, no such file or directory" error message when using fs.createWriteStream, check your file name again.

In my case, the last character is not the last character of file name, but carrage return (\r)

I lost 3 hours to find this simple answer. So I leave this memo.

@jankronquist
Copy link

Thank you for this! I had the exact same problem! I created a CSV file using Excel which probably messed up the filename.

@srMarquinho
Copy link

Thank you for saving me 3 hours.
I had spaces in the file path. dir / filename.xml.

@chriso86
Copy link

You, sir, are a legend.

@andrej-vasilj
Copy link

Also keep in mind that it won't create directories for you. This means that if you have any directories within the file path that don't exist it will throw this error.

@omchiii
Copy link

omchiii commented Apr 13, 2022

Also keep in mind that it won't create directories for you. This means that if you have any directories within the file path that don't exist it will throw this error.

thanks m8 , saved me a lot of time

@m1nka
Copy link

m1nka commented May 21, 2022

Also keep in mind that it won't create directories for you. This means that if you have any directories within the file path that don't exist it will throw this error.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment