-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Unexpected Token Error #394
Comments
Is this perhaps in a Node.js v12 or earlier environment? |
Node v16, same issue. |
Are you able to provide a reproducible case for this? The test suite is run on Node.js v14 and v16, so this is a bit surprising. |
Also, are you really sure that you're seeing this with Node.js 16? In my testing, this works:
But this fails:
|
Can't tell for OP, but yes, I have a Vue app using this library, and it is most certainly running Node v16 :) To be precise, Dockerfile building it uses 16.13, and on my computer it is 16.15 |
@Sintopp That's really curious. Perhaps there's some JS transpiler that's failing to parse the optional chaining? In any case, a reproducible case does seem needed here to diagnose the issue further. |
Also running Node v16. Will post a reproducible scenario if I can find one. |
Same error, different location:
It looks like this library recently switched to TypeScript. Perhaps that's related? Running Node 16.14.2, with a create-react-app on |
Thank you @FelicitusNeko, that gave me enough hints to investigate. This looks like it's caused by webpack/webpack#11186, and that the kind of solutions suggested by nuxt/nuxt#7722 (comment) do help resolve this. In other words, please try one of the following:
In my own testing, either of those was able to resolve this issue. If you're experiencing this and you're not using either |
Unfortunately, I am unable to upgrade |
@FelicitusNeko Have you tried adding |
The main problem is that Webpack no longer polyfills Node core modules. Even if I can get past that, I run into other issues for which tickets exist to be looked into further. I don't think adding |
@FelicitusNeko If you are not able to upgrade your tooling or add |
I'm seeing this problem as well. Adding Trying to bump webpack to So this is a no-go right now. |
@ericpromislow Are you able to provide a minimal reproduction of the problem you're experiencing? |
I don't have a self-contained repro, but since it's for an open-source project, here's how to experience it:
Many lines will now appear in the terminal, along the lines of:
All of the error messages are complaining of instances of This message:
is telling me I need to do something, but I'm not knowledgeable enough about the JS dialect world to know what that something should be. |
The issue you're hitting is nuxt/nuxt#9221, and the fix suggested there appears to work just like it should in your example: --- a/src/nuxt.config.js
+++ b/src/nuxt.config.js
@@ -32,6 +32,7 @@ export default {
loader: 'raw-loader',
});
},
+ transpile: ['yaml'],
},
buildDir: '../dist/nuxt',
buildModules: [ I'll close this issue at least for now, as this appears to consistently be an upstream issue in tools that depend on Webpack v4 or otherwise need additional configuration for parsing code that uses optional chaining. |
Hey, i'm not really sure but this doesn't seem like a tooling problem. I'm using esbuild to execute typescript files directly. In this typescript files i can use My tooling is basically:
And the script:
|
@MrWook You're using |
Without the But the issue remains that yaml is the only library that throws an error with a bundler. |
Ah, true, it's only a dev dependency there. Still, the upstream issue you've hit is this: |
How did it hit this upstream issue if |
Your other dependencies might not be using the nullish coalescing operator in their published source code, and your project's own code may be transpiled using different settings than your dependencies. |
Why is this closed? What's the fix? |
Here's the fix... reinstall everything. https://nodejs.org/en/download |
Found in: yaml/dist/compose/composer.js
if (prelude[i + 1]?.[0] !== '#')
Not expecting the period in between the
?
and[0]
.Threw errors when trying to run in some cases (failed on cron job execution).
Rolled back to v2.0.1 and that seemed to stop the issue from occurring.
Full Stack Trace
The text was updated successfully, but these errors were encountered: