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

Library is not compatible with Node 8.9.3 #270

Closed
utillity opened this issue Nov 6, 2022 · 6 comments
Closed

Library is not compatible with Node 8.9.3 #270

utillity opened this issue Nov 6, 2022 · 6 comments

Comments

@utillity
Copy link

utillity commented Nov 6, 2022

/.../node_modules/query-registry/dist/query-registry.cjs.development.js:747
  } catch {}
          ^
SyntaxError: Unexpected token {

/usr/share/gcui/node_modules/query-registry/dist/query-registry.cjs.development.js:139
    } catch {}
SyntaxError: Unexpected token {

it should be catch (err) { } as per MDN

@velut
Copy link
Owner

velut commented Nov 6, 2022

Hi @utillity, thanks for opening the issue.

On MDN, it says that the exception part can be omitted (see also their example):

exceptionVar Optional
An optional identifier to hold the caught exception for the associated catch block. If the catch block does not utilize the exception's value, you can omit the exceptionVar and its surrounding parentheses, as catch {...}.

The optional catch binding should be well supported by vendors and tools (see compatibility data).

Can you share some details about how you are getting the error (tools, Node or browser version, commands used) ?

@utillity
Copy link
Author

utillity commented Nov 6, 2022

Hi, I am using this library with node 8.9.3 on an embedded device (unfortunately I can't install a newer node version there). if you want to make it backward-compatible that would be great :)

I'm just using getPackageManifest({ name: packageName, registry: registry }) from your library

@utillity
Copy link
Author

utillity commented Nov 6, 2022

uff, looks like there are a couple of issues blocking me from using your library with node 8.9.3 - don't need to fix the catch :)

@velut
Copy link
Owner

velut commented Nov 6, 2022

That's unfortunate, what are the other issues if you don't mind? Maybe you could try compiling (part of) the library for your use case or use something like patch-package in your install step.

If you want to implement something yourself to fetch manifests from npm the endpoints look like this https://registry.npmjs.org/<bare name or scoped name>/<version or tag>, for example https://registry.npmjs.org/query-registry/2.6.0 or https://registry.npmjs.org/@types/node/latest.

@utillity
Copy link
Author

utillity commented Nov 6, 2022

this old nodejs version also doesn't support Object.fromEntries. I could pull and try to get everything working, if you need it. I found a simple workaround which works for me - I just use fetch() to get the JSON directly from my private repository, so no dependencies needed :)

@velut
Copy link
Owner

velut commented Nov 6, 2022

I see. Don't worry about the PR, supporting older versions is not a priority right now and I plan to use features available in current and future releases anyway (like native fetch).

I'm glad you found a solution that works for you.

@velut velut closed this as completed Nov 6, 2022
@velut velut changed the title catch {} causes SyntaxError: Unexpected Token Library is not compatible with Node 8.9.3 Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants