After installing nodejs from the scratch on a Linux Ubuntu 16.04.1 LTS (tested on 2 different servers, but same result...) browserify generates an incorrect bundle.js due to an extra weird character "Â". It happens only when using Web3 module. My browser throws "Unexpected token" when using it.
...
if (options.value > 0) {
var constructorAbi = abi.filter(function (json) {
return json.type === 'constructor' && json.inputs.length === args.length;
})[0] ||Â {}; // <===============================
if (!constructorAbi.payable) {
throw new Error('Cannot send value to non-payable constructor');
}
}
...
These are the packages I installed:
sudo apt-get update
sudo apt-get install -y nodejs npm git
npm cache clear --force
npm install -g npm
// A version manager for node.
sudo npm install -g n
sudo n stable
installed : v7.4.0
sudo npm install -g browserify
sudo npm install -g crypto
npm i --save-dev crypto
sudo npm install -g ethereumjs-util
npm i --save-dev ethereumjs-util
sudo npm install -g ethereumjs-tx
npm i --save-dev ethereumjs-tx
sudo npm install -g web3
npm i --save-dev web3
sudo npm install -g buffer
npm i --save-dev buffer
I also tried reinstalling Web3, but same result:
sudo npm uninstall -g web3
sudo npm install -g web3
npm i --save-dev web3
The modules I am using are the following:
vi main.js
var crypto = require("crypto");
var util = require("ethereumjs-util");
var Tx = require('ethereumjs-tx');
Web3 = require('web3');
Buffer = require("buffer").Buffer;
I have found it is Web3 module that makes the bundle.js to incorporate the weird char. By removing the weird char on bundle.js everything works fine.
Trying to find out if this is due to a badly encoded NBSP:
$ sed '25494q;d' bundle.js > line.txt
$ od -c line.txt
0000000 } ) [ 0
0000020 ] | | 302 240 { } ; \n
0000032
Any idea what is the reason of that character being there? Thx!