1

I am writing tests for my smart contract and when I type in "truffle test" I keep getting this error. Does anyone have an idea what might be wrong?

SyntaxError: Unexpected token export
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (native)
    at Mocha.loadFiles (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:536:10)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:125:1
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
1
  • Can you show us your test code? – Ismael Oct 9 '18 at 16:37
1

It should be fixed by adding the babel package:

https://github.com/trufflesuite/truffle/issues/664

You can check truffle.js in this Truffle Box:

https://github.com/adrianmcli/truffle-react

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.