The following guide consists in some notes on running node.js on Windows 7, along with some bugs and how to avoid them such that you can continue writing code using Windows 7 without worrying about node.js not supporting Windows 7 anymore.
Initially, node.js version v13.14.0 should be installed on Windows 7 because it is the latest official node.js version. The MSI package should be used to install node.js. Then, the latest node.js version for Windows 7 that works is v18.17.1 yet it must be downloaded as zip file and then extracted on top of the v13.6.0 existing node.js installation (typically to be found at C:\Program Files\nodejs\
).
Lastly, the NODE_SKIP_PLATFORM_CHECK
must be set in order to allow the node.js interpreter to proceed regardless of the platform not being supported.
os.hostname()
is broken on Windows 7 when using an unsupported node version, such that npm
, at the very least has to be patched in order to accept to work with hostnames and other addresses. Similarly, programs that use os.hostname()
have to be similarly patched in order to address the same issue. Fortunately, there is a very simple solution to the os.hostname()
bug, namely the package hostname-patcher
must be installed for all software packages and then referenced using require
. In other words simply execute:
npm install --save hostname-patcher
at the top-level of the software package directory in order to add hostname-patcher as a dependency and then add:
require('hostname-patcher')
at the top of the file.
The node package manager (npm) has the same os.hostname()
bug on Windows 7 and should be patched by adding hostname-patcher
as a dependency. This can be done by opening up the node.js installation directory, typically at C:\Program Files\nodejs\node_modules\npm\node_modules
and then either cloning the hostname-patcher
package:
git clone https://github.com/Bellisario/hostname-patcher
or just downloading "hostname-patcher" as a zip file and extracting it in the NPM node_modules
directory.
A good way to check whether the patch succeeded is to try and pass an alternate NPM registry on the command-line, ie:
npm login --registry https://npm.grimore.org
and then seeing whether the following error appears or not:
npm notice Log in on https://npm.grimore.org/ npm ERR! code ERR_SYSTEM_ERROR npm ERR! syscall uv_os_gethostname npm ERR! errno -4054 npm ERR! A system error occurred: uv_os_gethostname returned ENOSYS (function not implemented)
In case the previous error appears instead of prompting for a username and password, then the patch did not succeed and NPM must be patched again.