Node.js / NPM Flashcards
What is Node.js?
Node.js is a JavaScript runtime environment that executes JS code outside web browsers.
What can Node.js be used for?
Node.js is used for backend operations in JavaScript.
What is a REPL?
A Read-Eval-Print-Loop is a command-line tool for processing expressions.
What is a computer process?
An instance of a computer program being executed by one or many threads.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
At least 200.
Why should a full stack Web developer know that computer processes exist?
It is an important concept in apps made up of multiple components such as clients, servers, and databases.
What is the process object in a Node.js program?
An object that represents the current instance of the node process being run.
How do you access the process object in a Node.js program?
process exists as a global variable.
What is the data type of process.argv in Node.js?
Array of strings.
What is a JavaScript module?
single .js file with a standalone function.
What values are passed into a Node.js module’s local scope?
exports, require, module, __filename, __dirname
Give two examples of truly global variables in a Node.js program.
process, global
What is the purpose of module.exports in a Node.js module?
module.exports contains data that can be imported into other modules.
How do you import functionality into a Node.js module from another Node.js module?
const func = require(‘./func’);
What is the JavaScript Event Loop?
A design pattern that loops through the call stack and the callback queue, checking if the stack is empty and pushing functions onto it from the queue if it is.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking calls block further execution of functions in the stack until they return whereas non-blocking calls do not.
What is NPM?
Node Package Manager, made up of a website, a command-line interface, and a registry of software packages. The CLI installs and updates packages.
What is a package?
One or more modules grouped together.
How can you create a package.json with npm?
Navigate to root directory of package and execute “npm init [–yes]”.
What is a dependency and how do you add one to a package?
A dependency is a package needed to run another package. They are added by the command “npm install package-name [–save-prod]”.
What happens when you add a dependency to a package with npm?
When another user runs “npm install”, npm will install the dependencies listed in package.json.
What is a directory?
A file system cataloguing structure that contains references to other computer files and directories.
What is a relative file path?
A file path relative to the current directory.
What is an absolute file path?
A file path beginning from the root.