Posts

Showing posts with the label npm

The need for multi-platform npm packages

In this blog post, I argue that it should be possible to have multiple implementations of the same npm package (same name, same version). The problem At the moment, when you write an npm package, you can specify on what platforms it works, via the package.json property engines . For example : { "engines" : { "node" : ">=0.10.3 <0.12" } } { "engines" : { "npm" : "~1.0.20" } } That means that you can only have a single implementation per package. However, there are use cases for multiple implementations of the same package: For Node.js you can already use many ES6 features. For browsers, you should stay 100% ES5. There are Node.js-specific polyfills of Browser APIs. For example, node-fetch polyfills the fetch API. The module bundler Rollup needs the ES6 module format to achieve its superior file size savings. But that format doesn’t work anywhere else, yet. An idea for a solution I see two possible solutions: Al...

Installing past or future versions of npm packages

npm lets you install versions of packages other than the current one, via: npm install «package-name»@«tag» npm install «package-name»@«version» Installing tags Tags are aliases for versions. You can look up available tags via: npm view «package-name» dist-tags Example: $ npm view webpack dist-tags { latest: '1.12.9', beta: '2.0.1-beta' } Installing versions You can look up available versions via: npm view «package-name» versions Example: $ npm view webpack versions [ '0.1.0', '0.1.1', ··· '1.12.8', '1.12.9', '2.0.0-beta', '2.0.1-beta' ]