Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 12 latest ES syntax compatibility #803

Closed
sulkaharo opened this issue May 16, 2019 · 3 comments
Closed

Node 12 latest ES syntax compatibility #803

sulkaharo opened this issue May 16, 2019 · 3 comments

Comments

@sulkaharo
Copy link

sulkaharo commented May 16, 2019

The JOSE library seems to use a lot of the latest ES syntaxes introduced in Node 12: https://github.com/panva/jose Using the library in a project with Node 12.2.0 and ESM, when loading the library, this error is produced and the application fails to start.

node_modules/@panva/jose/lib/jwe/encrypt.js:77
  [PROCESS_RECIPIENT] (recipient) {
                      ^
SyntaxError: Invalid or unexpected token
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)

You can easily reproduce this:

mkdir test
cd test
npm create
npm install esm
npm install panva/jose

Paste this to index.js:

const jose = require('@panva/jose')

const {
  JWE,   // JSON Web Encryption (JWE)
  JWK,   // JSON Web Key (JWK)
  JWKS,  // JSON Web Key Set (JWKS)
  JWS,   // JSON Web Signature (JWS)
  JWT,   // JSON Web Token (JWT)
  errors // errors utilized by @panva/jose
} = jose

then run both node index.js and node -r esm index.js and you'll get the error when ESM is used.

@dbo
Copy link

dbo commented May 16, 2019

I am experiencing similar syntax problems with 3.2.23 (3.2.22 is ok) running on node 10.15, recent syntax errors reported per #804, too:

  [formatSymbol](formatter, context) {
                ^

SyntaxError: Invalid or unexpected token

@Skywalker13
Copy link

Looks same here with Symbol.iterator (works perfectly with previous release 3.2.22)

/private/node_modules/node-fetch/lib/index.js:908
        [Symbol.iterator]() {
                  ^

SyntaxError: Invalid or unexpected token
    at Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Object.require.extensions.(anonymous function) (/private/node_modules/babel-register/lib/node.js:152:7)

@jdalton
Copy link
Member

jdalton commented May 16, 2019

Moving to #804.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants