This question already has answers here:
node.js REPL "undefined"
(4 answers)
Closed 7 years ago.
I'm putting together a training video for the basics of Node. I'm demonstrating REPL and it seems no matter what I do I get "undefined". I've read several posts here and everyone seems to say it's normal because javascript always returns null but it just seems odd and I think my viewers will think I'm an idiot.
Is there anyway to turn it off or am I doing something wrong? I've attached a screen shot of some very simple stuff that returns undefined
This worked for me in windows:
node -e "require('repl').start({ignoreUndefined: true})"
Related
This question already has answers here:
Check for current Node Version
(10 answers)
Closed 1 year ago.
I would like to know the current version of Node, such as the one obtained by the command line "node -v", but via a js function.
The NodeJS global object property process.version might be what you need.
This question already has answers here:
'this' different between REPL and script
(2 answers)
Closed 4 years ago.
//test.js
console.log(this);
By executing the test.js with command 'node test.js', I got result of '{}'. But by executing the same code in REPL, I got tons of system information. Why this difference? Is it because of my configuration of Node?
Different execution contexts.
In node, any file you require is a module that has its own scope, by default an empty object (hence the {}), until you export something.
The repl, on the other hand, is its own execution context with a bunch of stuff already attached to it. You can even set things up to attach to it yourself (e.g. Convenient functions)
This question already has answers here:
ReferenceError: describe is not defined NodeJs
(8 answers)
Closed 6 years ago.
Trying to use Mocha for unit testing. The Getting Started instructions are straightforward enough at first:
Install Mocha with npm install --global mocha
Create a file called test.js
Edit the file and paste some predefined stuff into it
All great, so far. But then, "Back in the terminal":
Array
#indexOf
...etc
Ok, I'm totally baffled. Obviously, it doesn't mean to type this on the command line. But I tried running node and doing a require('<test file>'); to no avail. Edit: The module does not load (I had said it does). Running require('assert') does work, but that does me no good. I can run Array().indexOf(), but that has nothing to do with my testing.
What does this last instruction really mean? What am I really supposed to do to get this framework going so I can use it for unit testing?
Edit: Also tried require('assert'); followed by require('mytest.js'); also with no joy.
Edit: just got a clue that Array().indexOf() is just JS code, having nothing to do with mocha or the assert module. But still, no luck with mocha.
Edit: As for there already being an answer to this question, there is no way I could have known that this was about a reference error. Reference error was only one of many failures that occurred during my wild grasping. The real problem is that the mocha instructions are not clear, and that makes this question totally different from the one about the reference error.
You can run your test with mocha test.js. That is the part they are missing in the 'Getting Started' in order to generate the output mentioned.
This question already has answers here:
How to access internal resources from background.js
(3 answers)
Closed 6 years ago.
Every page on the internet seems to suggest a different option for this, and who knows what's deprecated and what isn't. What's the "correct" way to read a file from within the extension bundle? I don't want to inline the data into the script files themselves, both because it's awful practice and because it consumes an unnecessary amount of memory.
Fetch is the newest and easiest. It works in all cases except getting a list of the packaged files at runtime, which requires chrome.runtime.getPackageDirectoryEntry.
fetch("manifest.json").then(function(response) {
return(response.json())
}).then(function(manifest) {
console.log(manifest)
})
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
This question already has answers here:
What happened to regtlibv12?
(3 answers)
Closed 3 years ago.
I have Visual Studio 2015 running on Windows 10 and need to register a legacy type lib (.tlb). From the posts I've found, regtlibv12.exe is the tool for this. However, I can't find it under C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ or anywhere else for that matter. Does anyone know how to register .tlb if regtlibv12.exe doesn't exist?
I've tried regasm /tlb:path but I get errors saying the path cannot be read.
Any help would be much appreciated.
You need to get the old regtlibv12.exe from an older machine.
I upgraded to Windows 10 and lost the function but found it here:
C:\Windows.old\Windows\Microsoft.NET\Framework\v4.0.30319
works fine.