summaryrefslogtreecommitdiff
path: root/runtime/fmt_errors.rs
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-11-14 14:11:29 +0100
committerGitHub <noreply@github.com>2024-11-14 13:11:29 +0000
commitde34c7ed29bcce8b46a65f5effe45090b8493ba5 (patch)
tree5dc23f03d87522682342f0f82215566e8e580298 /runtime/fmt_errors.rs
parent4e899d48cffa95617266dd8f9aef54603a87ad82 (diff)
feat(cli): add `--unstable-node-globals` flag (#26617)
This PR adds a new `--unstable-node-globals` flag to expose Node globals by default. Fixes https://github.com/denoland/deno/issues/26611 --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/fmt_errors.rs')
-rw-r--r--runtime/fmt_errors.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs
index 28cd70296..6c05fbc63 100644
--- a/runtime/fmt_errors.rs
+++ b/runtime/fmt_errors.rs
@@ -339,28 +339,40 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
FixSuggestion::info(cstr!(
"<u>Buffer</> is not available in the global scope in Deno."
)),
- FixSuggestion::hint(cstr!("Import it explicitly with <u>import { Buffer } from \"node:buffer\";</>.")),
+ FixSuggestion::hint_multiline(&[
+ cstr!("Import it explicitly with <u>import { Buffer } from \"node:buffer\";</>,"),
+ cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
+ ]),
];
} else if msg.contains("clearImmediate is not defined") {
return vec![
FixSuggestion::info(cstr!(
"<u>clearImmediate</> is not available in the global scope in Deno."
)),
- FixSuggestion::hint(cstr!("Import it explicitly with <u>import { clearImmediate } from \"node:timers\";</>.")),
+ FixSuggestion::hint_multiline(&[
+ cstr!("Import it explicitly with <u>import { clearImmediate } from \"node:timers\";</>,"),
+ cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
+ ]),
];
} else if msg.contains("setImmediate is not defined") {
return vec![
FixSuggestion::info(cstr!(
"<u>setImmediate</> is not available in the global scope in Deno."
)),
- FixSuggestion::hint(cstr!("Import it explicitly with <u>import { setImmediate } from \"node:timers\";</>.")),
+ FixSuggestion::hint_multiline(
+ &[cstr!("Import it explicitly with <u>import { setImmediate } from \"node:timers\";</>,"),
+ cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
+ ]),
];
} else if msg.contains("global is not defined") {
return vec![
FixSuggestion::info(cstr!(
"<u>global</> is not available in the global scope in Deno."
)),
- FixSuggestion::hint(cstr!("Use <u>globalThis</> instead, or assign <u>globalThis.global = globalThis</>.")),
+ FixSuggestion::hint_multiline(&[
+ cstr!("Use <u>globalThis</> instead, or assign <u>globalThis.global = globalThis</>,"),
+ cstr!("or run again with <u>--unstable-node-globals</> flag to add this global."),
+ ]),
];
} else if msg.contains("openKv is not a function") {
return vec![