tech/webdev magazine

January 11, 2017

How to write a JavaScript package for both Node and the browser

Wednesday, January 11, 2017 Teklinks

This is an issue that I’ve seen a lot of confusion over, and even seasoned JavaScript developers might have missed some of its subtleties. So I thought it was worth a short tutorial. Let’s say you have a JavaScript module that you want to publish to npm, available both for Node and for the browser. But there’s a catch! This particular module has a slightly different implementation for the Node version compared to the browser version.

Full article