openpgpjs / web-stream-tools

Convenience functions for reading, transforming and working with WhatWG Streams
MIT License
27 stars 15 forks source link

Cannot run in node #1

Closed samelliottdlt closed 3 years ago

samelliottdlt commented 5 years ago

To reproduce:

npm i web-stream-tools require('web-stream-tools')

Results in this error:

/node_modules/web-stream-tools/lib/streams.js:1
(function (exports, require, module, __filename, __dirname) { import { isStream, isUint8Array, concatUint8Array } from './util';
                                                                     ^

SyntaxError: Unexpected token {

This code made its way into my dependencies by way of openpgpjs. Is this intended to only run in the web?

Using node v10.15.3

twiss commented 5 years ago

Hey :wave: The way that this code, and openpgpjs itself, is intended to run in Node is by running babel on it first. For openpgpjs, the published package on npm already contains a babelified build, but this package doesn't. If you wish, a PR to fix that would be welcome. Otherwise, a quick-and-dirty way to access this library in Node would be:

npm i openpgp require('openpgp').stream