Package Installation / Uninstallation Commands
- These are commands for installing/uninstalling external module packages.
1. Package Installation #
- Command:
npm install<package_name> - Installs the package into the current project's node_modules folder.
- It is also automatically added to the
dependenciessection of thepackage.jsonfile.In the past, to add a package to
dependencies, you would install it withnpm install --save <package_name>. However, since npm@5, this is the default behavior, so--saveis no longer necessary. - Can be abbreviated as
npm i<package_name>. - You can specify the version with
npm install <package_name>@<version>. - You can specify the package installation address with
npm install <address>.
2. Installing Multiple Packages #
- Command:
npm install <package1> <package2> <package3>... - Installs multiple packages simultaneously.
3. Global Installation #
- Command:
npm install -global 패키지명 - Installs the package in the folder where npm itself is installed, making it accessible from anywhere.
On Mac and Linux, you might need to install it with
sudo, likesudo npm i --global <package_name>.
Can be abbreviated as
npm i -g 패키지명.
4. Development Installation #
- Command:
npm install --save-dev 패키지명 - Installs it so that it's added to the
devDependenciessection of thepackage.jsonfile.
Can be abbreviated as
npm i -D.
5. Installation Using package.json File #
- Command:
npm install - When you run the command in the folder where the
package.jsonfile is saved, it automatically installs all packages listed in thedependenciessection.
6. Package Uninstallation #
- Command:
npm uninstall 패키지명 - Deletes the package installed in the
node_modulesfolder. It is also removed from thedependenciessection ofpackage.json.
Can be abbreviated as
npm rm 패키지명.