Skip to content

Patches os.hostname() for Windows 7 devices using a not officially Node.js supported version

License

Notifications You must be signed in to change notification settings

Bellisario/hostname-patcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hostname Patcher License NPM version Build Status Opened Issues Monthly Downloads

Patches os.hostname() for Windows 7 devices using a not officially Node.js supported version

Installation

npm install hostname-patcher

Use cases

For some strange reason, os.hostname() is always broken if you're using a version of Node.js not officially supported in Windows 7 (v14.x.x and above), so, this module aims to keep it working.

News: Now also patched devices will have the real hostname, instead of the default "localhost".

Don't want to use it? (Worried about adding this?)

You'll not have any problem using this patch, because it checks if it's needed before doing its work (see here).

How to use

Common.js

To use with Common.js, just require it without even any variable assignment:

// require patch first
require('hostname-patcher');
// then os
const os = require('os');
// or module using os module
const { moduleUsingOS } = require('example');

// will output your real hostname if patch and if not
console.log(os.hostname());

ES6

To use as an ES6 module, just import it:

// import patch first
import 'hostname-patcher';
// then os
import os from 'os';
// or module using os module
import { moduleUsingOS } from 'example';

// will output your real hostname if patch and if not
console.log(os.hostname());

All examples available in the examples folder.

Tested modules

For modules builders

Even if single projects can use this patch individually, would be great if modules themselves start using it, because it's a lot better for users experience and more practical.
I know that this error occurs because these new Node.js versions are not anymore officially supported by Windows 7, but still today is a very usable and light OS for a lot people, so, please, keep supporting it, even if the Node.js community (but not everybody) want anymore.

About

Patches os.hostname() for Windows 7 devices using a not officially Node.js supported version

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project