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

A way to forget a variable in Node.js REPL? #56752

Closed
geeksilva97 opened this issue Jan 24, 2025 · 1 comment
Closed

A way to forget a variable in Node.js REPL? #56752

geeksilva97 opened this issue Jan 24, 2025 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.

Comments

@geeksilva97
Copy link
Contributor

What is the problem this feature will solve?

It's just a tiny improvement for the REPL.

Take the following sample of REPL usage when a typo happened.

> const { DatabaseSync } = require('node:sqliite');
Uncaught Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:sqliite
    at Function._load (node:internal/modules/cjs/loader:1068:13)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:141:16) {
  code: 'ERR_UNKNOWN_BUILTIN_MODULE'
}
> const { DatabaseSync } = require('node:sqlite');
Uncaught SyntaxError: Identifier 'DatabaseSync' has already been declared

Note that due to a typo, I can't use require again to import DatabaseSync. Instead, I usually close and open the reply.

What is the feature you are proposing to solve the problem?

Implementing a way to forget a variable would solve it.

The Erlang programming language doesn't allow reassignment, so a situation like the one described above might occur. To solve this, they have a utility function for forgetting a variable.

In the example below we can reuse Message after calling f(Message).

Image

NOTE: That would be good. However, I don't know of a way to do this in the current REPL. Please let me know if there's one.

What alternatives have you considered?

Using let when importing in REPL :)

@geeksilva97 geeksilva97 added the feature request Issues that request new features to be added to Node.js. label Jan 24, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Jan 24, 2025
@bnoordhuis
Copy link
Member

See #8309 (comment) - tl;dr known issue that is fixable but requires a lot of work and no one (to my knowledge) has stepped up so far.

Since this is a duplicate of an existing bug report, I'll go ahead and close it out.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
@bnoordhuis bnoordhuis added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Feb 3, 2025
@targos targos closed this as completed Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.
Projects
Archived in project
Development

No branches or pull requests

3 participants