0
0
Node.jsframework~5 mins

Running scripts with node command in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the node command do?
The node command runs JavaScript files outside the browser using the Node.js runtime.
Click to reveal answer
beginner
How do you run a script named app.js using Node.js?
You run it by typing node app.js in the terminal or command prompt.
Click to reveal answer
intermediate
What happens if you run node without any file name?
Node.js opens an interactive REPL (Read-Eval-Print Loop) where you can type JavaScript commands and see results immediately.
Click to reveal answer
intermediate
Can you run a script with Node.js if the file is not in the current directory?
Yes, you provide the relative or absolute path to the file, like node ./scripts/app.js or node /home/user/app.js.
Click to reveal answer
advanced
What is the purpose of the --inspect flag when running a Node.js script?
The --inspect flag starts the script with debugging enabled, allowing you to connect a debugger to inspect the code while it runs.
Click to reveal answer
How do you start running a JavaScript file named server.js with Node.js?
Anode server.js
Bnpm server.js
Cjs server.js
Drun server.js
What does Node.js open if you run node without any arguments?
AA web server
BAn error message
CA REPL to type JavaScript commands
DA file explorer
Which of these commands runs a script located in a subfolder called scripts?
Anode ./app.js
Bnode scripts/app.js
Cnode app.js scripts
Dnode /app.js
What does the --inspect flag do when running a Node.js script?
AEnables debugging mode
BRuns the script faster
CMinifies the code
DPrevents errors
If your script file is named index.js, which command is correct to run it?
Anode run index.js
Bnode index
Cnode .js index
Dnode index.js
Explain how to run a JavaScript file using Node.js from the terminal.
Think about the command format: node + filename
You got /3 concepts.
    Describe what happens when you run the node command without any script file.
    It’s like a mini JavaScript playground in your terminal.
    You got /3 concepts.