NPM basic scripts
JavaScript
Basic npm (Node Package Manager) commands for Windows users
Initialize a New Project
npm initCreates a package.json file interactively.
Use npm init -y to create it with default settings.
Install Dependencies from package.json
npm installInstalls all dependencies listed in package.json.
Install a Package Locally
npm install <package-name>or
npm i <package-name>Example:
npm i expressInstalls express in the current project.
Install a Package Globally
npm install -g <package-name>Example:
npm i -g nodemonInstalls nodemon globally for system-wide use.
Uninstall a Package
npm uninstall <package-name>or
npm rm <package-name>Example:
npm uninstall expressList Installed Packages
npm listor for global packages:
npm list -g --depth=0Update a Package
npm update <package-name>Example:
npm update expressCheck for Outdated Packages
npm outdatedClear npm Cache
npm cache clean --forceRun a Script (Defined in package.json)
npm run <script-name>Example:
npm run startCheck npm Version
npm -vChecks the installed version of npm.
Check Node.js Version
node -vChecks the installed version of Node.js.