-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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 --experimental-modules don't give the code where to find the error, just Invalid or unexpected token. Eg v.8.9.1 #17277
Comments
the |
yes, but my post is about node does not show where is the error, file and line... |
Okay, so the test case can be simplified to: await async () => {}; // t.mjs And then you get a decent error message with:
And a rather less useful one with:
The error message is slightly different when it's in an imported module but it's the same basic bug. |
okey, I get the error in another situations too with no detailed error message, my post is not to get support about the await problem... but I this a bug ? why with --experimental-modules i dont get the error ? what about if i want to start a new project just with --experimental-modules ? |
@webmobiles See #17281, it's going to get fixed. |
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: nodejs#17277 PR-URL: nodejs#17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: #17277 PR-URL: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Include the offending line in the output and underline the bad token. Before this commit, it printed "SyntaxError: Unexpected reserved word" without indicating where the syntax error is. Now it prints the line and underlines the offending token, like it does for syntax errors in CJS scripts. Minor changes are made to the test runner in order to support `*.mjs` files in test/message. Fixes: #17277 PR-URL: #17281 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
I'm testing projects renaming js to .mjs in order to execute them with --experimental-modules
they are proyects running ok with babel.
But I keep guessing where the error can be found on my code. I get always an error that it's hard to find:
(node:16709) ExperimentalWarning: The ESM module loader is experimental.
SyntaxError: Invalid or unexpected token
at ModuleJob.loaders.set [as moduleProvider] (internal/loader/ModuleRequest.js:32:13)
at
by example I can copy this example code where the error is produced, but it's not only with this situation but in anothers too. Why Node don't give me the line and the code that produces the error ? maybe it's better I try with node 9 ? that version is more compatible with --experimental-modules ?
Example code:
test.js
connection.jms (this file have errors , by example using require() or anothers, but the idea is to get display errors that help you to find errors )
I execute with:
node --experimental-modules ./src/test.mjs
again I repeat the error message:
Version: 8.9.1
Platform: Mac ElCapitan
The text was updated successfully, but these errors were encountered: