๐Ÿ“— How to write cross-platform Node.js code

Overview

License Twitter Medium

How to write cross-platform Node.js code.

Why you should care: according to the 2018 Node.js user survey, 24% of Node.js developers use Windows locally and 41% use Mac. In production 85% use Linux and 1% use BSD.

Table of contents

Summary

๐Ÿค– Development environment

๐Ÿ“ File encoding

๐Ÿ“‚ Filesystem

๐Ÿ’ป Terminal

๐Ÿ”’ Security

๐Ÿ“ก Networking / IPC

๐ŸŽ›๏ธ System

See also

Support

For any question, don't hesitate to submit an issue on GitHub.

Everyone is welcome regardless of personal background. We enforce a Code of conduct in order to promote a positive and inclusive environment.

Contributing

This project was made with โค๏ธ . The simplest way to give back is by starring and sharing it online.

If the documentation is unclear or has a typo, please click on the page's Edit button (pencil icon) and suggest a correction.

If you would like to help us fix an error or add more information, please check our guidelines. Pull requests are welcome!

Thanks go to these wonderful people:

ehmicky
ehmicky

๐Ÿ’ป ๐ŸŽจ ๐Ÿค” ๐Ÿ“–
thatalextaylor
thatalextaylor

๐Ÿค” ๐Ÿ“–
Ben Noordhuis
Ben Noordhuis

๐Ÿค” ๐Ÿ“–
Steve Lee
Steve Lee

๐Ÿค” ๐Ÿ“ข
Michael J. Ryan
Michael J. Ryan

๐Ÿค”
Fabio Spampinato
Fabio Spampinato

๐Ÿค”
AyrA
AyrA

๐Ÿค”
Felix Becker
Felix Becker

๐Ÿ“– ๐Ÿค”
Nicola Dal Maso
Nicola Dal Maso

๐Ÿค”
Comments
  • Add section on portable `npm run` scripts

    Add section on portable `npm run` scripts

    [Excellent work and comprehensive. I've being doing portable dev for years (actually since DOS)]

    A closely related issues is writing npm scripts that are portable. Often a little care goes a long way but there are limitations and that might causeyou to reach for somehting like shx. Or just use Makefiles :)

    I'll dig up an old post it did and link it here.

    opened by SteveALee 13
  • Fix typo in README.md: s/htime/hrtime/

    Fix typo in README.md: s/htime/hrtime/

    Aside: even though process.hrtime() returns nanoseconds, the actual resolution is usually much coarser. On Linux, for example, it's usually no better than 100 ns (0.1 us) and often much worse. I wouldn't single out Windows.

    opened by bnoordhuis 7
  • Clarification about stat.birthtime

    Clarification about stat.birthtime

    I've noticed the readme says:

    On the other hand the birthtime and birthtimeMs values are undefined on Unix.

    Assuming that you were talking about unix-y systems and not exactly Unix I can't reproduce this on both macOS and Lubuntu:

    Screen Shot 2019-03-12 at 16 06 24

    Screen Shot 2019-03-12 at 16 05 04

    So I'm not sure what to take of that. Has this been "fixed" in more recent versions of node? Does it only happen on some specific filesystems? Are you actually talking about the Unix here?

    Thanks!

    opened by fabiospampinato 5
  • Added link from 'time.md' to the

    Added link from 'time.md' to the "Terminal" index page

    Great project!

    Which problem is this pull request solving?

    Since at the end of every other section there is a link to the following "chapter", I thought I could add a link in the last page of the "System" chapter (Time) to the "Terminal" chapter.

    Let me know if it was wanted, or it just slipped by. ๐Ÿ˜ƒ

    I also noticed that the "Terminal" chapter index page has the "Previous" link to the last page of the File System chapter. Do you want me to fix it as well?

    Checklist

    Please add a x inside each checkbox:

    opened by niktekusho 4
  • Improve several points regarding Windows

    Improve several points regarding Windows

    Which problem is this pull request solving?

    Some points regarding Windows are erroneous.

    This was reported by @ayra on Reddit.

    Please note few points inside that Reddit comments have not been added because:

    • the guide already mentions them:
      • Newlines in Windows are always CRLF, never just LF.
      • CTRL+Z does end streams in Windows but only in text mode, not when reading in binary mode.
    • while this works on Windows, this does not lead to the best cross-platform behavior:
      • While you should avoid common device names as file/directory names in Windows (COM1,COM2,etc.) you can use them normally using the long file name syntax \\?\
      • No reason to avoid uppercase characters on Windows.
    • others:
      • TCP servers can listen on a file descriptor in Windows and If you mean an internal socket by "File descriptor" this is done via anonymous or named pipes in Windows.: see note at end of https://nodejs.org/api/net.html#net_server_listen_handle_backlog_callback

    Checklist

    Please add a x inside each checkbox:

    • [x] I have read the contribution guidelines.
    • [x] The status checks are successful (continuous integration). Those can be seen below.
    opened by ehmicky 4
  • Mention WSL

    Mention WSL

    WSL is now a very usable option on Windows, though is still slow. However I beelive we should still write for cmd / PS portability.

    BTW I use Git for Windows bash as my main shell and it works a treat for me. It's based on the old MSYS / MinGW system which I always prefered to Cygwin (actually might use MSYS2) However npm always launches cmd for child shells so you still need portable npm scripts. :(

    opened by SteveALee 3
  • Added 'aux' as a reserved Windows file name

    Added 'aux' as a reserved Windows file name

    As listed in the Windows file naming conventions (as linked from the original document), aux is also a reserved file name. This change makes the list of reserved names the same as the source.

    opened by thatalextaylor 3
  • Bump prismjs from 1.20.0 to 1.21.0

    Bump prismjs from 1.20.0 to 1.21.0

    Bumps prismjs from 1.20.0 to 1.21.0.

    Release notes

    Sourced from prismjs's releases.

    v1.21.0

    Release 1.21.0

    Changelog

    Sourced from prismjs's changelog.

    1.21.0 (2020-08-06)

    New components

    Updated components

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Make `CONTRIBUTING` link absolute, and center the logo

    Make `CONTRIBUTING` link absolute, and center the logo

    ๐ŸŽ‰ Thanks for sending this pull request! ๐ŸŽ‰

    See:

    • bcoe/awesome-cross-platform-nodejs#32
    • bcoe/awesome-cross-platform-nodejs#36
    opened by hong4rc 1
  • Proposal of buffer-encoding, cross-sqlcipher

    Proposal of buffer-encoding, cross-sqlcipher

    Awesome work!

    Here's some of my proposal

    • For encoding converting: https://www.npmjs.com/package/buffer-encoding
    • For encryption on sqlite: https://www.npmjs.com/package/cross-sqlcipher
    opened by fritx 1
  • Unsafe signals recommendation

    Unsafe signals recommendation

    The README currently says this:

    only use process.on(signal) with the following signals: [..] SIGILL, [..] SIGFPE, SIGSEGV

    The docs however strongly recommend against listening for those signals:

       * `'SIGBUS'`, `'SIGFPE'`, `'SIGSEGV'` and `'SIGILL'`, when not raised
       artificially using kill(2), inherently leave the process in a state from
       which it is not safe to attempt to call JS listeners. Doing so might lead to
       the process hanging in an endless loop, since listeners attached using
       `process.on()` are called asynchronously and therefore unable to correct the
       underlying problem.
    
    opened by bnoordhuis 1
Releases(1.1.1)
Owner
ehmicky
Node.js back-end developer
ehmicky
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022
Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test and also deploy.

GraphQL Blog graphqlblog.com Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test an

GraphQLApps 6 Aug 17, 2022
Cross platform terminal app from Visual Studio Code.

CodeTerminal Standalone terminal from Visual Studio Code. Installation macOS Highly recommanded to install with homebrew. brew tap xcodebuild/custom b

xcodebuild 673 Dec 21, 2022
A cross-platform Node app that publishes a LogSeq journal as a blog via Drummer

myLogseqBlog A cross-platform Node app that publishes a LogSeq journal as a blog via Drummer How to install Download the app from the repo. It's a .zi

Dave Winer 14 Jul 23, 2022
Democratic Platform to write anti-political stuffs

nLog Natural Way Of Blogging. By writing politcally incorrect things uwu Built using ( MERN STACK ) Try Now [ Deployment is online ( hopefully ) ] Try

Somnath Das 3 Dec 17, 2022
A cross-platform AutoHotKey-like thing with TypeScript as its scripting language

suchibot A cross-platform AutoHotKey-like thing with JavaScript/TypeScript as its scripting language. Built on top of uiohook-napi and nut.js. Install

Lily Scott 79 Sep 21, 2022
LucaMail - an Open Source,Cross Platform Email Client

LucaMail v0.0.1-beta An Awesome Cross Platform Email Client! Note : This Project Is Still in Beta Version Website . Report Bug . Request Feature . Dis

Yuva raghav 210 Dec 28, 2022
Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

51pwn 29 Jan 8, 2023
A cross-platform systray library for Deno.

deno-systray A cross-platform systray library for Deno using the go systray library. Usage import SysTray from "https://deno.land/x/systray/mod.ts";

Robert Soriano 10 Jul 16, 2022
A cross-platform desktop application of tools for developers

A cross-platform desktop application of tools for developers ?? Online Web This website provides online version of the same tools echoo ?? Offline Cli

Kyle 133 Dec 24, 2022
Opensource Cross-platform Logitechยฎ Litra Glow control

Litra Opensource Cross-platform Logitechยฎ Litra Glow control Requirements Linux sudo echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}==

zource.dev 9 Nov 19, 2022
The Slip Snapper is a cross-platform application that assists in managing an individualsโ€™ expenses.

The Slip Snapper is a cross-platform application that assists in managing an individualsโ€™ expenses. It will accomplish this by allowing a user to scan their receipts using optical character recognition (OCR) with a mobile device and create comprehensive expense reports.

COS 301 - 2022 7 Dec 7, 2022
A tiny cross-platform client for SQLite3, with precompiled binaries as the only third-party dependencies.

Tiny SQLite3 A tiny cross-platform client for SQLite3, with precompiled binaries as the only third-party dependencies. A nice feature about this modul

Fabio Spampinato 19 Oct 27, 2022
A cross-platform browser extension that changes the way seasons are display on Crunchyroll.

Crunchyroll With Better Seasons Crunchyroll With Better Seasons is a cross-platform browser extension that changes the way seasons are displayed on Cr

null 9 Nov 4, 2022
Webview is a tiny cross-platform library to make web-based GUIs for desktop applications.

webview_deno deno bindings for webview Webview is a tiny cross-platform library to make web-based GUIs for desktop applications. โš ๏ธ This project is st

webview 1.2k Jan 2, 2023
TimezoneDB is an easy, cross-platform method of keeping track of others' timezones.

TimezoneDB TimezoneDB is an easy, cross-platform method of keeping track of others' timezones. This project is inspired by PronounDB, and we'd like to

Synapse Technologies, LLC 13 Nov 16, 2022
Cross platform UI controls for progressive web and hybrid apps (plain JS, jQuery, Angular and React)

Mobiscroll What is Mobiscroll? Mobiscroll is a UI library for progressive webapps and hybrid development. Created with a lot of attention to usability

Mobiscroll 1.5k Dec 31, 2022
Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

David Sherret 150 Dec 31, 2022
Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

David Sherret 45 Jul 24, 2022