HearthSim / hearthstone-deckstrings

🔗 Decode and encode Hearthstone Deckstrings.

Home Page:https://hearthsim.info/docs/deckstrings/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Unexpected token import

LeetCodes opened this issue · comments

hi, i get this error when attempting to run the example code? i ran the install command and created a index.js file with the example code but get the following error

/Users/michael/node/deckstrings-test/index.js:1
(function (exports, require, module, __filename, __dirname) { import {encode, decode} from "deckstrings";
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:449:3

Hey there! import/export is not supported by node (yet!) - just replace it with the following line:

const {encode, decode} = require("deckstrings");

Closing as this should be solved.

commented

In E-6 import work fine and my friend wright the es6 code perfectly so it should work it is the problem in typescript or node version

@rajatprogrammer Indeed, it works in Node now, with the version v8.5.0 released on September 12th 2017. You'll see this issue is from July 2017 though, so at the time Node was not able to do ES6 modules. Typescript is not related to this issue.

commented

please help me in this code syntax