Installing web3-provider-engine package break build
npm run build should work without errors
> react-scripts build
Creating an optimized production build...
Failed to compile.
static/js/main.18c39de7.js from UglifyJs
SyntaxError: Unexpected token: name (senderHex) [./~/eth-sig-util/index.js:43,0]
Run these commands in the project folder and fill in their results:
npm ls react-scripts (if you haven鈥檛 ejected):
node -v:
v6.10.1
npm -v:
3.10.10
Then, specify:
Operating system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
Browser and version:
create-react-app coolproj
cd coolproj
npm i -S web3-provider-engine
Then modify index.js:
import ProviderEngine from 'web3-provider-engine';
import WalletSubprovider from 'web3-provider-engine/subproviders/wallet.js';
import Web3Subprovider from 'web3-provider-engine/subproviders/web3.js';
Then npm run build
Demo repo : https://github.com/gagarin55/create-react-app-build-error
A library called eth-sig-util (likely a dependency of web3-provider-engine) is shipping uncompiled ES6:
function getPublicKeyFor (msgParams) {
let senderHex
const message = ethUtil.toBuffer(msgParams.data)
const msgHash = ethUtil.hashPersonalMessage(message)
This breaks Uglify which doesn鈥檛 support ES6. We intentionally don鈥檛 compile node_modules with Babel because it鈥檚 slow and potentially can break some code.
Your best bet would be to either precompile the library and its dependencies to ES5 yourself, ask the library maintainers to do it, or eject and add node_modules/eth-sig-util as one of the included folders to the Babel Webpack configuration.
Most helpful comment
A library called
eth-sig-util(likely a dependency ofweb3-provider-engine) is shipping uncompiled ES6:This breaks Uglify which doesn鈥檛 support ES6. We intentionally don鈥檛 compile
node_moduleswith Babel because it鈥檚 slow and potentially can break some code.Your best bet would be to either precompile the library and its dependencies to ES5 yourself, ask the library maintainers to do it, or eject and add
node_modules/eth-sig-utilas one of theincluded folders to the Babel Webpack configuration.