erc721
erc721 copied to clipboard
SyntaxError: Cannot use import statement outside a module
Hi,
I followed all the instructions in the README.md, and truffle test
doesn't work for the following reason.
(base) quinn@quinn:~/erc721-clone$ truffle test
Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js.
Using network 'test'.
Compiling your contracts...
===========================
> Compiling ./contracts/MyERC721.sol
> Artifacts written to /tmp/test--345458-YKQDT3lb0jSz
> Compiled successfully using:
- solc: 0.4.23+commit.124ca40d.Emscripten.clang
Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js.
/home/quinn/Documents/nftca/erc721-clone/test/erc721.spec.js:1
import chai from 'chai'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at compileFunction (<anonymous>)
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at /usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:390:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:387:14)
at Mocha.run (/usr/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:961:10)
at /usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:151:1
at new Promise (<anonymous>)
at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:150:1)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/test/index.js:
192:1)
at Command.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
Truffle v5.2.2 (core: 5.2.2)
Node v14.16.0```
I tried switching import chai from 'chai' to const { chai } = require('chai') and the variable chai is coming back undefined.