Explore how to set up a basic REST API using NodeJS and Express, manage dependencies, and serve both static files and data. This quiz covers foundational backend development concepts in a NodeJS environment.
Which approach is recommended to ensure you install a stable and reliable version of NodeJS for backend development?
Explanation: Downloading the most stable release ensures you get a reliable version suitable for production use, minimizing the risk of bugs and future incompatibility. Beta versions may contain unstable features. Cloning the source code is unnecessary for most users and can be complex. Relying on pre-installed versions may provide outdated software.
What is the primary purpose of the package.json file in a NodeJS application?
Explanation: The package.json file holds essential information about the app and lists all dependencies, making it easy to manage and share projects. JavaScript compilation and user authentication are not handled by package.json. Backing up static files is unrelated to its function.
Which command interactively creates a package.json file while initializing a new NodeJS project?
Explanation: Running 'npm init' interactively generates the package.json file, prompting for input. 'node start' is not a valid initialization command. 'npm install express' installs Express but does not create package.json by itself. 'npm script create' is not a recognized npm command.
What does the -g flag do when installing the express-generator tool with npm?
Explanation: The -g flag installs a module globally, making it accessible from anywhere on your system. It does not generate files, update all global packages, or change module priority.
What is the key difference between serving static files and serving data in a NodeJS backend?
Explanation: Static files like HTML, CSS, and JavaScript are delivered unchanged, while data responses can be dynamically generated or processed by the server. Authentication is not inherent to either, and both static files and data responses can vary in format.