Closed mirao closed 4 years ago
This is what I'm getting when using the syntax in your docs:
$ node -r esm client.js
/home/mirao/workspace/javascript/ydkjs/modules/students.js:3
export getName;
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
@saebrabaebra you have to unwatch a repository to stop getting notifications on new issues.
@mirao -- sorry, that is a mistake, should have been export { getName };
. will fix.
Edition: 2nd
Book Title: You Don't Know JS Yet: Scope & Closures - 2nd Edition
Chapter: Chapter 8: The Module Pattern
Section Title: Modern ES Modules (ESM)
Problem: The statement
export getName;
doesn't work me with NodeJS 10.x and ESM module (node -r esm client.js
), I'm getting "SyntaxError: Invalid or unexpected token".I think the right syntax is
export { getName };
, see also MDN docs. Or you can use an alternative suggested by IntelliSense in VScode: