bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.62k stars 2.09k forks source link

ERROR: Unexpected token: name (createHash) #1221

Closed davidapple closed 5 years ago

davidapple commented 5 years ago

When running browserify -r bitcoinjs-lib -s bitcoin | uglifyjs > bitcoinjs.min.js

I get the following error:

Parse error at 0:245,4
let createHash = require('create-hash')
    ^
ERROR: Unexpected token: name (createHash)
    at JS_Parse_Error.get (eval at <anonymous> (/usr/local/lib/node_modules/uglify-js/tools/node.js:20:1), <anonymous>:71:23)
    at fatal (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:291:53)
    at run (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:235:9)
    at Socket.<anonymous> (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:168:9)
    at Socket.emit (events.js:164:20)
    at endReadableNT (_stream_readable.js:1054:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
dabura667 commented 5 years ago

What are the outputs to the following 3 commands?

node -v
npm -v
browserify --version
davidapple commented 5 years ago
node v9.2.0
npm v5.5.1
browserify v16.2.2
dcousens commented 5 years ago

@davidapple that isn't a browserify issue. That is an uglifyjs issue (read your stack trace).

10 seconds looking at the uglifyjs documentation showed me:

uglify-js only supports JavaScript (ECMAScript 5).

Please read the documentation of what you are using.

junderw commented 5 years ago

@davidapple Uninstall uglifyjs and install uglify-es (The command stays the same)

https://www.npmjs.com/package/uglify-es