Coder Social home page Coder Social logo

bellisario / hostname-patcher Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 2.0 70 KB

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

License: MIT License

JavaScript 100.00%
hostname nodejs patch windows-7

hostname-patcher's Introduction

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.

hostname-patcher's People

Contributors

bellisario avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

arunstop kaloat01

hostname-patcher's Issues

how can I add this globaly

Hi you did wonderfull work, thank you

was wonderin if there is any way to somehow add this globaly
because right now I need to add this ontop of every project and it gets confusing for people that don't have the os.gethostname problem because they are running an os where GetHostName is supported and since node will probably never add the solution proposed here: nodejs/node#40353

we need to figure out some more global aproach I guess

I know that a longterm solution for window7 will probably be this: https://github.com/vxiiduu/VxKex

So yea, hope you are allright

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.