



























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This exam tests deep familiarity with Node Version Manager (nvm), version management workflows, environment automation, shell scripting patterns, and contribution requirements for nvm. Candidates configure multi-version environments, resolve conflicting dependencies, test version switching edge cases, and participate in documentation and script enhancement exercises.
Typology: Exams
1 / 99
This page cannot be seen from the preview
Don't miss anything!




























































































Question 1. Which command installs the latest LTS version of Node.js using nvm? A) nvm install node B) nvm install --lts C) nvm install latest-lts D) nvm install lts Answer: B Explanation: The --lts flag tells nvm to download and install the most recent Long‑Term‑Support release. Question 2. After running the curl install script for nvm, which line should you add to ~/.bashrc to make nvm available in new shells? A) source ~/.nvm/nvm.sh B) export NVM_DIR=~/.nvm &&. "$NVM_DIR/nvm.sh" C). /usr/local/nvm/nvm.sh D) alias nvm='~/.nvm/nvm.sh' Answer: B Explanation: The official recommendation is to set NVM_DIR and source nvm.sh in the profile script. Question 3. What does the command nvm ls-remote --lts display? A) All Node versions ever released B) Only the versions currently installed locally C) Remote LTS versions available for installation D) Versions that have been deprecated
Answer: C Explanation: --lts filters the remote list to show only Long‑Term‑Support releases. Question 4. Which of the following indicates the currently active Node version when you run nvm ls? A) An asterisk (*) next to the version B) A caret (^) before the version C) An arrow (→) pointing to the version D) The version appears in bold Answer: C Explanation: nvm ls marks the active version with an arrow ->. Question 5. To switch the current shell to Node.js version 16.14.0, you would run: A) nvm use 16.14. B) nvm switch 16.14. C) nvm set 16.14. D) nvm activate 16.14. Answer: A Explanation: nvm use <version> changes the active Node version for the current shell. Question 6. What does the command nvm alias default 14.19.3 accomplish? A) Sets 14.19.3 as the system Node version B) Creates a shortcut named “default” that points to 14.19. C) Makes 14.19.3 the version used in every new terminal session
Question 9. Which environment variable does nvm rely on to locate its installation directory? A) NODE_HOME B) NVM_DIR C) NVM_PATH D) NODE_ENV Answer: B Explanation: NVM_DIR points to the folder where nvm stores versions and scripts. Question 10. After installing a new Node version, you want to copy all globally installed npm packages from version 10.24.1 to the new version. Which flag achieves this? A) --copy-packages-from=10.24. B) --reinstall-packages-from=10.24. C) --migrate-global=10.24. D) --clone-packages=10.24. Answer: B Explanation: The --reinstall-packages-from option reinstalls global packages from the given older version. Question 11. Which command clears nvm’s download cache? A) nvm cache clean B) nvm cache clear C) nvm clear-cache D) nvm purge
Answer: B Explanation: nvm cache clear removes cached tarballs and compiled binaries. Question 12. When you run command - v nvm and get no output, what is the most likely cause? A) nvm is not installed B) The profile script that sources nvm.sh was not reloaded C) The nvm binary is missing from /usr/local/bin D) Node.js is not installed Answer: B Explanation: nvm is a shell function; if the profile script isn’t sourced, the command won’t be found. Question 13. Which of the following statements about nvm uninstall <version> is true? A) It removes the version and all its global npm packages B) It only removes the binary, leaving global packages behind C) It prompts for confirmation before deletion D) It also removes the .nvmrc file in the current directory Answer: A Explanation: Uninstalling a version deletes its directory, which includes its global node_modules. Question 14. To verify which exact executable path is used for Node version 20.5.0, you would run:
Question 17. What does the nvm exec <version> npm test command do? A) Switches the shell to npm test B) Runs npm test in a subshell using the specified Node version, leaving the current shell unchanged C) Installs the test package for the given version D) Creates a new terminal window with that version Answer: B Explanation: nvm exec runs a command in a temporary environment with the chosen version. Question 18. Which file is commonly placed at the root of a repository to enforce a specific Node version for all contributors? A) .node-version B) .nvmrc C) .nodeenv D) .nvm-config Answer: B Explanation: .nvmrc contains the version string that nvm reads. Question 19. When using the manual Git installation method for nvm, which command clones the repository into $HOME/.nvm? A) git clone https://github.com/nvm-sh/nvm.git $HOME/.nvm B) git pull https://github.com/nvm-sh/nvm.git ~/.nvm C) git checkout nvm $HOME/.nvm D) git init https://github.com/nvm-sh/nvm ~/.nvm
Answer: A Explanation: git clone copies the repository to the target directory. Question 20. After installing nvm via the curl script, which command verifies the installed nvm version? A) nvm --version B) nvm version C) nvm - v D) nvm info Answer: A Explanation: nvm --version prints the version of the nvm script. Question 21. Which command would you use to install Node.js from source instead of a pre‑compiled binary? A) nvm install 14.17.0 --source B) nvm install 14.17.0 --compile C) nvm install 14.17.0 --build-from-source D) nvm install 14.17.0 --source-code Answer: C Explanation: The --build-from-source flag forces compilation from the source tarball. Question 22. If you want nvm to automatically load the version specified in .nvmrc when you cd into a directory, which shell hook is commonly used in Bash? A) PROMPT_COMMAND
Question 25. Which command would you use to list only the versions that are currently installed and also indicate which one is the default? A) nvm list --default B) nvm ls --default C) nvm ls - a D) nvm ls Answer: D Explanation: nvm ls shows installed versions and marks the default alias with a default - > line. Question 26. If you encounter “nvm: command not found” after installing via the wget script, what is the most likely remedy? A) Reinstall Node.js globally B) Add source ~/.nvm/nvm.sh to your shell profile and reload it C) Run npm install - g nvm D) Delete the .nvm directory and reinstall Answer: B Explanation: The script installs nvm but you still need to source its script in your profile. Question 27. What does the nvm alias command do? A) Creates a shortcut name for a specific Node version B) Sets the default version for the system C) Lists all installed versions D) Removes a version from nvm Answer: A
Explanation: nvm alias <name> <version> creates a named alias that can be used with nvm use. Question 28. Which of the following commands will display the version of npm that belongs to the currently active Node version? A) npm --version B) nvm npm --version C) nvm which npm --version D) node - p "process.versions.npm" Answer: A (or D also works, but the direct answer expected) Explanation: Once a Node version is active, the npm command in the PATH belongs to that version, so npm --version reports it. Question 29. You have two Node versions installed: 12.22.9 and 14.19.2. Which command will delete only version 12.22.9? A) nvm remove 12.22. B) nvm uninstall 12.22. C) nvm delete 12.22. D) nvm purge 12.22. Answer: B Explanation: nvm uninstall <version> removes that particular version. Question 30. To set a custom download mirror for nvm (useful behind a corporate proxy), which environment variable should you define? A) NVM_MIRROR
Explanation: nvm detects existing installations and simply notes that the requested version is present. Question 33. Which of the following is NOT a valid way to specify a version to nvm use? A) 14.17. B) v14.17. C) lts/* D) node/* Answer: D Explanation: node/* is not a recognized alias; node alone refers to the latest current version, but the wildcard pattern is invalid. Question 34. If you want to temporarily use a version without affecting the global default, which command is appropriate? A) nvm use nvm exec runs a command with the chosen version in a subshell, leaving the default unchanged. Question 35. Which of the following best describes what happens when you run nvm install 10? A) Installs the exact version 10.0.
B) Installs the latest 10.x.x version (e.g., 10.24.1) C) Installs the latest LTS version that starts with 10 D) Returns an error because a full semver is required Answer: B Explanation: Providing only the major number causes nvm to install the most recent patch release of that major line. Question 36. After switching to a new Node version, you notice that globally installed packages are missing. Why? A) nvm deletes global packages on each switch B) Each Node version has its own isolated global node_modules directory C) npm automatically clears globals when version changes D) The PATH no longer includes the global bin directory Answer: B Explanation: nvm isolates global packages per version; they are not shared across versions. Question 37. Which command will display all defined aliases, including default? A) nvm alias list B) nvm alias C) nvm ls-aliases D) nvm show-alias Answer: B Explanation: Running nvm alias without arguments lists all aliases.
Answer: B Explanation: nvm version prints the Node version that is currently in use. Question 41. Which command will list only the LTS versions that are already installed locally? A) nvm ls --lts B) nvm ls-remote --installed --lts C) nvm ls | grep - i lts D) nvm ls-remote | grep LTS Answer: A Explanation: The --lts flag works with nvm ls to filter installed versions to LTS only. Question 42. When you run nvm install node --reinstall-packages-from=system, what does “system” refer to? A) The version that ships with the operating system B) The version that is currently active in the shell before the install command C) The default alias defined in nvm D) The latest LTS version Answer: B Explanation: system tells nvm to copy global packages from the version that was active before the new install. Question 43. If you want to force nvm to download a binary even when a compiled source is available, which flag do you use?
A) --binary B) --download-only C) --skip-compile D) --no-build Answer: A Explanation: --binary tells nvm to fetch the pre‑compiled tarball instead of building from source. Question 44. Which line should you add to ~/.zshrc to enable automatic loading of .nvmrc files when you change directories? A) autoload - U add-zsh-hook && add-zsh-hook chpwd nvm_auto_use B) setopt AUTO_NVMRC C) source ~/.nvm/nvm.sh && nvm use D) PROMPT_COMMAND='nvm use' Answer: A Explanation: Zsh uses add-zsh-hook chpwd to run a function (often named nvm_auto_use) after each directory change. Question 45. After installing nvm, you notice that node - v still returns the system Node version. What is the most likely cause? A) nvm was installed but not sourced in the current shell B) Node was installed with Homebrew and overrides nvm C) The node binary is cached in /usr/local/bin D) nvm only works with npm, not the node binary
B) The list includes both source tarballs and binary builds C) The output is sorted alphabetically D) The command only shows versions newer than the currently installed one Answer: B Explanation: nvm ls-remote lists all remote releases, indicating both source and binary options. Question 49. When you run nvm install 12.22.9 --reinstall-packages-from=10.24.1, what happens to the global packages from version 10.24.1? A) They are copied verbatim to the new version’s global folder B) They are reinstalled using npm under the new version C) They are ignored because the flag only works for LTS versions D) nvm prompts you to confirm each package Answer: B Explanation: The flag triggers npm to reinstall each global package in the context of the new version. Question 50. If a project’s .nvmrc file contains only the major number 16, what version will nvm use select? A) The latest 16.x.x version available locally B) The latest 16.x.x version available remotely (and installs it if missing) C) It will fail because a full semver is required D) It will select the version defined in the default alias Answer: B
Explanation: nvm interprets a single major number as “latest patch of that major”, fetching it if not present. Question 51. Which command will display the location of the nvm installation directory? A) echo $NVM_DIR B) nvm location C) nvm path D) which nvm Answer: A Explanation: The environment variable NVM_DIR holds the path to the nvm folder. Question 52. After running nvm install node, you want to set this newly installed version as the default for all future shells. Which command accomplishes this? A) nvm alias default node B) nvm use node --default C) nvm set default node D) nvm default node Answer: A Explanation: Creating an alias named default that points to node makes it the default. Question 53. Which of the following will list all Node versions that are currently cached but not yet installed? A) nvm cache list B) nvm cache ls C) nvm cache show