How do I download a file with Node.js without using third-party libraries?
I don't need anything special. I only want to download a file from a given URL, and then save it to a given directory.
downloadfsjavascriptnode.js
How do I download a file with Node.js without using third-party libraries?
I don't need anything special. I only want to download a file from a given URL, and then save it to a given directory.
Best Answer
You can create an HTTP
GET
request and pipe itsresponse
into a writable file stream:If you want to support gathering information on the command line--like specifying a target file or directory, or URL--check out something like Commander.