A developer needs to install the uglify-js command-line tool on a Linux server to minify JavaScript files. The tool must be accessible from any directory in the user's shell. Which of the following commands should be used to accomplish this?
The correct command is npm install -g uglify-js. The -g (or --global) flag instructs npm to install the package in a global location, making its binaries available in the system's PATH for execution from any directory. Installing without the -g flag would place the package in a local node_modules directory, and its binary would not be in the user's PATH by default. The apt command is used for system-level Debian/Ubuntu packages, not for installing packages from the npm registry. npm add is an alias for npm install, but global uglify-js is not the correct syntax for a global installation.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
Why is the -g flag necessary in npm installations?
Open an interactive chat with Bash
How does a globally installed npm package become accessible from any directory?
Open an interactive chat with Bash
Can apt be used to install JavaScript packages like uglify-js?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access