NodeJS Basics Flashcards

1
Q

What is the purpose of the package.json file?

A

This file contains metadata for the project, such as the name, version, dependencies (libraries), and so on. Given a package.json file, other people can download and install the same libraries and run tests in the same way that the original creator did.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is it not recommended to save and share the node_modules folder?

A

because it contains a large number of files, can be platform-specific, and the package.json file already lists dependencies for easy installation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What key advantage does it offer in terms of programming languages?

A

Using the same programming language for both frontend and backend.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of Node.js

A

Allows running JavaScript code on the server-side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command do you use to run a Node.js application from the command line?

A

node [file.js]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you access the Node.js REPL environment, and what does REPL stand for?

A

Open a terminal and type node to access the Node.js REPL environment. REPL stands for “read, evaluate, print, and loop”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Syntax for installing modules with NPM?

A

npm install [module_name]

installs external modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is one of the core tasks of Node.js in the backend of web applications?

A

handle HTTP requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

primary tasks of NPM?

A

Managing, downloading, and installing external modules into projects or the operating system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you initiate a Node repository using NPM?

A

npm init

(to initialize a Node repository)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of npm init?

A

npm init is used to initialize a Node.js project and create a package.json file to manage project details and dependencies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does npm init create upon execution?

A

npm init creates a package.json file that contains metadata about the project, including its name, version, description, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can you customize the initialization process with npm init?

A

Yes, you can provide flags like --yes or -y to skip the prompts and accept default values, or use -f to force initialization without prompts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s inside the node_modules folder, and why is it better not to share it?

A

The node_modules folder stores library code from online places. It’s smarter to list libraries in package.json and use NPM to get them. This is easier and less error-prone as you don’t need to store and manage the libraries yourself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can another user use the package.json file to get libraries, and why is it better?

A

They run npm install on their computer, and NPM sets up a node_modules folder with dependencies from package.json. This avoids tracking all the files and versions separately in version control.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When can Node.js be a bottleneck?

A

Node.js can struggle with CPU-intensive tasks like numerical computations. It uses a single thread, making such tasks slow and potentially locking the entire app.

17
Q

What is Node.js commonly recommended for?

A

Node.js is recommended for applications involving I/O operations, such as handling web requests, file operations, and real-time communication, due to its non-blocking, event-driven architecture.