SyntaxError: Unexpected token export
See original GitHub issueHello,
I tried add zeppelin-solidity
(1.7.0) to the react-box and run the test cases. I modified test/simplestorage.js
to below
import ether from 'zeppelin-solidity/test/helpers/ether';
var SimpleStorage = artifacts.require("./SimpleStorage.sol");
contract('SimpleStorage', function(accounts) {
it("...should store the value 89.", function() {
return SimpleStorage.deployed().then(function(instance) {
simpleStorageInstance = instance;
return simpleStorageInstance.set(89, {from: accounts[0]});
}).then(function() {
return simpleStorageInstance.get.call();
}).then(function(storedData) {
assert.equal(storedData, 89, "The value 89 was not stored.");
});
});
});
When I run the truffle test
command, it throws Unexpected token export
error
11:31 $ truffle test test/simplestorage.js
Using network 'development'.
/Users/jacktang/Code/genome_block/node_modules/zeppelin-solidity/test/helpers/ether.js:1
(function (exports, require, module, __filename, __dirname) { export default function ether (n) {
^^^^^^
SyntaxError: Unexpected token export
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:537:28)
at Module._extensions..js (module.js:584:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/jacktang/Code/genome_block/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
How can I fix this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Getting Unexpected Token Export - javascript - Stack Overflow
I solved it by declaring a type as a module when adding a script tag in my index.
Read more >SyntaxError: Unexpected token 'export' in JavaScript [Fixed]
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >How to Solve Unexpected Token 'export' Error in JavaScript
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >How to fix SyntaxError: Unexpected token 'export' in JavaScript?
In this article, we are going to see How to fix SyntaxError: Unexpected token 'export' in JavaScript? and what are Es6 modules.
Read more >Unexpected token 'export' : r/typescript - Reddit
Try setting " "type": "module", " in you package.json . This causes node to handle *.js files as EsModule files, instead of as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@atulkc @kimyd
Since this Truffle box hasn’t been updated in a long time, I’ve made a new Truffle Box to compete with this current one. In my truffle box (https://github.com/adrianmcli/truffle-react), I have integrated Babel into the Truffle project itself.
I also personally tested the latest zeppelin-solidity library with it. You can do the following in your test with no problems:
I tried to make the Truffle Box account for the most popular errors in this repo’s issue tracker. So I’ve also moved the frontend to its own separate folder, made sure React is not ejected, and also upgraded to Web3 1.0.
Hope this helps you guys.
@adrianmcli Thanks for the clarification. I ended up taking the plunge and migrated to your box. Took most of the day, but the setup seems vastly simpler and quite a lot better now. Thanks a lot!