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

const beavior when erroring to set a module #16520

Closed
luislobo opened this issue Oct 26, 2017 · 2 comments
Closed

const beavior when erroring to set a module #16520

luislobo opened this issue Oct 26, 2017 · 2 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. repl Issues and PRs related to the REPL subsystem.

Comments

@luislobo
Copy link

I normally use the repl, to test out modules before actually using them.

Today I run into an issue that I don't really know if it's an issue or a "feature".

node                                                                                                                                                                                                                                                                                                                       ⬡ 8.7.0 ◇ 5.5.1  [±PETRO-797-guidon-export ●]
> const m = require('invalid-module-name-goes-here')
Error: Cannot find module 'invalid-module-name-goes-here'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at repl:1:11
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
> const m = require('invalid-module-name-goes-here')
SyntaxError: Identifier 'm' has already been declared

> m
ReferenceError: m is not defined
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)
> 
(To exit, press ^C again or type .exit)
> 

So, basically, you require a non existent module, assigning it to a const identifier. Then, when you try to redefine it (may be typing the correct module name, it doesn't matter much) it says it has been already declared, but after inspecting it, it says it's not defined.

So, weather the last reference error is wrong, saying it's not defined. Or may be there is a slight difference between defined and declared?

@mscdex mscdex added the repl Issues and PRs related to the REPL subsystem. label Oct 26, 2017
@Ginden
Copy link

Ginden commented Oct 26, 2017

Duplicate: #8441 #8376 #8309

@bnoordhuis
Copy link
Member

@Ginden beat me to it. :-) Closing, known issue; please see the other bug reports.

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. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants