Ganache-cli: `SyntaxError: Unexpected token =` on launch

Created on 2 Dec 2016  路  5Comments  路  Source: trufflesuite/ganache-cli

I installed v3.0.2 on Ubuntu 15.10, and when I launch testrpc I get:

$ testrpc 
/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/index.js:29
function VM (opts = {}) {
                  ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/hooked.js:6:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Expected Behavior

TestRPC should start.

Current Behavior

It fails immediately on start.

Possible Solution

Steps to Reproduce (for bugs)

  1. Show versions
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:        15.10
Codename:       wily
$ nodejs --version
v4.4.7
  1. Install
$ sudo npm -g install [email protected]
  1. Run
$ testrpc 
/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/index.js:29
function VM (opts = {}) {
                  ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/hooked.js:6:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Context

I have to fallback to v2.0.9

Your Environment

  • Version used: v3.0.2
  • NodeJS: 4.4.7
  • Server type and version: Virtualbox VM with 1.5GB RAM
  • Operating System and version: Ubuntu 15.10

Most helpful comment

This is a duplicate of #206. Unfortunately ethereumjs-vm has upgraded their code to ES6 now that Node 6.9.1 is set for long term support. You'll need to upgrade your node version to 6.x or above (I believe) in order to use the TestRPC at this time.

There are ways around this as mentioned in #206. Alternatively you can write a Node script that launches a TestRPC server and registers with Babel at the top of the file, which will convert ES6 code to ES5.

All 5 comments

This is a duplicate of #206. Unfortunately ethereumjs-vm has upgraded their code to ES6 now that Node 6.9.1 is set for long term support. You'll need to upgrade your node version to 6.x or above (I believe) in order to use the TestRPC at this time.

There are ways around this as mentioned in #206. Alternatively you can write a Node script that launches a TestRPC server and registers with Babel at the top of the file, which will convert ES6 code to ES5.

A fix that worked for me (installs later version of node):

    wget http://nodejs.org/dist/latest-v8x/node-v8.4.0-linux-x64.tar.gz  
    sudo tar -C /usr/local --strip-components 1 -xzf node-v8.4.0-linux-x64.tar.gz

you might have to change the distribution based on your cpu architecture, see this

Reference

The address has changed a bit:
OS: Ubuntu 16.04 64bit

wget https://nodejs.org/dist/v8.8.0/node-v8.8.0-linux-x86.tar.gz
sudo tar -C /usr/local --strip-components 1 -xzf node-v8.8.0-linux-x86.tar.gz

I highly recommend creationix/nvm for anyone having this issue.

nvm install lts
nvm use lts
npm install -g ethereumjs-testrpc

benjamincburns suggestion of using nvm solved the issue for me, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zweicoder picture zweicoder  路  3Comments

redshark1802 picture redshark1802  路  4Comments

SCBuergel picture SCBuergel  路  5Comments

axic picture axic  路  5Comments

varasev picture varasev  路  3Comments