Is there a way to log the Node.js version to a file instead of the console?

Responsive Ad Header

Question

Grade: Education Subject: Support
Is there a way to log the Node.js version to a file instead of the console?
Asked by:
75 Viewed 75 Answers

Answer (75)

Best Answer
(250)
Yes, you can redirect the output of the `node -v` command to a file. For example, on Linux/macOS, you can use: `node -v > version.txt`. On Windows, you would use: `node -v > version.txt`. This will save the version string into the `version.txt` file.