Install Npm Packages Flashcards
What command is used to install a package locally in npm?
npm install <package-name></package-name>
True or False: The command ‘npm install -g <package-name>' installs a package globally.</package-name>
True
What flag is used with npm install to save a package as a development dependency?
–save-dev
Fill in the blank: The command ‘npm install <package-name> --save-dev' adds the package to the \_\_\_\_\_\_\_\_ section of package.json.</package-name>
devDependencies
What does the ‘-g’ flag stand for in ‘npm install -g <package-name>'?</package-name>
global
Which command would you use to install a package globally and save it as a dev dependency?
npm install -g <package-name> --save-dev</package-name>
What is the default installation scope for npm packages if no flag is specified?
local
True or False: Using ‘npm install <package-name>' will add the package to the dependencies in package.json.</package-name>
True
What command can be used to install multiple packages at once?
npm install <package1> <package2> ...</package2></package1>
What does the command ‘npm install <package-name> --save' do?</package-name>
It saves the package as a dependency in package.json.
Fill in the blank: To uninstall a package, you would use the command ‘npm ________ <package-name>'.</package-name>
uninstall
What is the purpose of the package.json file in a Node.js project?
It manages project dependencies and scripts.
True or False: All npm packages can be installed globally.
False
What does the ‘–no-save’ flag do when installing an npm package?
It prevents the package from being added to package.json.
Which command would you use to install a specific version of a package?
npm install <package-name>@<version></version></package-name>
True or False: The command ‘npm install’ without any arguments installs all dependencies listed in package.json.
True
What command would you use to check for outdated npm packages?
npm outdated
What is the purpose of the ‘node_modules’ directory?
It stores all the installed npm packages for a project.
Fill in the blank: The command ‘npm ________ <package-name>' updates a package to the latest version.</package-name>
update