XJavascript.com
Toggle Menu
Home
Online Javascript Compiler
Tutorials
JavaScript Tutorials
TypeScript Tutorials
Blog
All Posts
NPM and Package Management
Review your understanding of npm,yarn,and dependency management.
1. What is the primary purpose of the 'npm init' command?
Initialize a new NPM project (creates package.json)
Install a specific package from the registry
Uninstall all installed dependencies
Update NPM to the latest version
2. Which file in an NPM project contains metadata such as project name, version, and dependencies?
package.json
package-lock.json
node_modules
.npmrc
3. The 'package-lock.json' file is automatically generated to lock the exact versions of installed dependencies.
True
False
4. What command is used to install a package as a development dependency? (format: npm install <flag> <package>; include the flag)
5. Which of the following are valid dependency types in a package.json file?
dependencies
devDependencies
peerDependencies
globalDependencies
6. What does the '-g' flag indicate when used with 'npm install <package>'?
Install the package globally
Install as a development dependency
Install the latest prerelease version
Ignore version constraints in package.json
7. Which command is used to uninstall a locally installed NPM package?
npm uninstall <package>
npm remove <package>
npm delete <package>
npm erase <package>
8. Which NPM commands can be used to update installed dependencies?
npm update
npm upgrade
npm install <package>@latest
npm outdated
9. Dev dependencies are required for the application to run in production.
True
False
10. What does 'NPM' stand for?
11. What is the primary purpose of the 'npx' command?
Execute a package without installing it globally
Install a package globally
Update all project dependencies
Publish a package to the NPM registry
12. In semantic versioning (semver), what does the 'MINOR' number in 'MAJOR.MINOR.PATCH' represent?
Backward-compatible new features
Breaking changes
Bug fixes
Build metadata
13. Which files/directories should typically be excluded from version control (e.g., Git) in an NPM project?
node_modules/
package.json
package-lock.json
.npmrc
14. Running 'npm install' without any arguments installs all dependencies listed in package.json.
True
False
15. What is the shorthand alias for the 'npm install' command?
16. What is the purpose of the 'npm audit' command?
Scan for security vulnerabilities in installed dependencies
Uninstall unused dependencies
Update all dependencies to their latest versions
Run a custom build script
17. Which version specifiers in package.json will install version 2.3.4 or higher but less than 3.0.0?
^2.3.4
~2.3.4
2.x
>=2.3.4 <3.0.0
18. What is a 'scoped package' in NPM?
A package namespaced under a user/organization (e.g., @angular/core)
A package installed globally
A deprecated package marked for removal
A package with no dependencies
19. Peer dependencies specified in package.json are automatically installed by NPM.
True
False
20. Name the file that records exact versions of all installed dependencies to ensure reproducible builds.
Reset
Answered 0 of 0 — 0 correct