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

SyntaxError: Unexpected token 'with' #837

Open
wrrnlim opened this issue Nov 13, 2024 · 2 comments
Open

SyntaxError: Unexpected token 'with' #837

wrrnlim opened this issue Nov 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@wrrnlim
Copy link

wrrnlim commented Nov 13, 2024

Bug Report

Describe the bug

Getting the following error in Node v20:

file:///yahooFinance/node_modules/yahoo-finance2/dist/esm/src/lib/validateAndCoerceTypes.js:3
import pkg from "../../package.json" with { type: "json" };
                                     ^^^^

SyntaxError: Unexpected token 'with'
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:118:18)
    at callTranslator (node:internal/modules/esm/loader:273:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:30)

Node.js v20.9.0

Minimal Reproduction

Run the following using Node v20:

import yahooFinance from 'yahoo-finance2';

const results = await yahooFinance.quoteSummary('NVDA');
console.log(results);

Environment

Browser or Node: Node
Node version (if applicable): v20.9.0
Npm version: 10.1.0
Browser verion (if applicable): N/A
Library version (e.g. 1.10.1): 2.13.2

Additional Context

@wrrnlim wrrnlim added the bug Something isn't working label Nov 13, 2024
@wrrnlim
Copy link
Author

wrrnlim commented Nov 13, 2024

Looks like this is related to #800; Node v22 uses with but v20 uses assert?

@gadicc
Copy link
Owner

gadicc commented Dec 21, 2024

Hey @wrrnlim, thanks for the report and for your patience. Slowly catching up on my backlog.

However, you did actually correctly report the related issue. This was a bit of bad planning on the node team's part, because, there was no overlap or grace time, you had to choose one or the other (one version would crash, and the other would work). So we used assert for v20 for a while and eventually switched to with for v22, once node v20 ended it's "active" version period.

Usually we would have supported v20 throughout it's maintenance period too, but in this case, we had to choose one or the other (or publish two separate versions of yahoo-finance, which is beyond the capabilities of our small team, unfortunately).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants