pokusew / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
59 stars 55 forks source link

Unexpected token when running example #18

Closed emond07 closed 5 years ago

emond07 commented 6 years ago

Hi,

Im having problem with the sample code. Im using node v11

C:\Program Files\nodejs\node.exe --inspect-brk=31374 nfc-pcsc\examples\basic.js Debugger listening on ws://127.0.0.1:31374/44f7c3dd-ad54-42e3-90ad-014997bf8ae2 For help, see: https://nodejs.org/en/docs/inspector Debugger attached. c:\Users\emond\Desktop\nfc\nfc-pcsc\examples\basic.js:8 import { NFC } from "../src/index.js"; ^

SyntaxError: Unexpected token { at new Script (vm.js:80:7) at createScript (vm.js:264:10) at Object.runInThisContext (vm.js:316:10) at Module._compile (internal/modules/cjs/loader.js:670:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10) at Module.load (internal/modules/cjs/loader.js:605:32) at tryModuleLoad (internal/modules/cjs/loader.js:544:12) at Function.Module._load (internal/modules/cjs/loader.js:536:3) at Function.Module.runMain (internal/modules/cjs/loader.js:760:12) at startup (internal/bootstrap/node.js:308:19) Waiting for the debugger to disconnect... SyntaxError: Unexpected token { vm.js:80 at new Script (vm.js:80:7) at createScript (vm.js:264:10) at Object.runInThisContext (vm.js:316:10)

Psychopoulet commented 5 years ago

you just have the wrong node version. you should upgrade it.

pokusew commented 5 years ago

Incorrect usage. Solved here https://github.com/pokusew/nfc-pcsc/issues/50. See https://github.com/pokusew/nfc-pcsc/issues/50#issuecomment-437625961.

Psychopoulet commented 5 years ago

in fact, this syntaxe with import/export is correct for last version of node, so I guess there is just an upgrade (and some recompilations to do) https://nodejs.org/docs/latest-v11.x/api/esm.html be warned, it's an experimental feature and you have to enable it lucky us, with the last versions we will not need recompilations in the future, it should be the last ones.