Node.js, NPM and Vue.js Commands Guide
In this article, you can learn the most important commands for Node.js, NPM and Vue.js and easily understand what they do.
Node.js Commands
Here are the basic commands you will use when working with Node.js:
| Command | Explanation |
|---|---|
| node -v | Shows the Node.js version. |
| node [file.js] | Runs the specified JS file. |
| node | Opens REPL (interactive environment) in terminal. |
NPM Basic Commands
NPM (Node Package Manager) is used for package management in Node.js projects. Here are the basic commands:
| Command | Explanation |
|---|---|
| npm -v | Shows the NPM version. |
| npm init | Starts a new project and creates package.json. |
| npm init -y | Creates package.json with default settings. |
| npm install [package] | Installs the specified package. |
| npm install -D [package] | Installs as a development dependency. |
| npm uninstall [package] | Removes the package from the project. |
| npm update | Updates all dependencies. |
| npm list --depth=0 | Lists the installed major dependencies. |
| npm outdated | Shows packages that need to be updated. |
| npm start | Runs the "start" script. |
| npm run [command] | Runs defined custom scripts. |
| npm restart | It runs the restart script in package.json. If this script is not defined, it runs the stop and start scripts, respectively. It can also run lifecycle hooks such as prerestart and postrestart. |
| npm ci | Performs a clean install (based on package-lock.json). |
| npm rebuild | Recompiles native modules. |
| npm cache clean --force | Clears the NPM cache. |
| npm config list | Lists NPM configurations. |
| npm doctor | It scans the NPM and Node.js environment to check for potential configuration and system issues. |
| npm help | Shows help about commands. |
| npm install -g [package] | Installs the package globally. |
| npx [komut] | Temporarily runs packages within the project or downloaded from the internet. |
NPM Advanced Commands
Here are some advanced NPM commands you can use for more advanced package management:
| Command | Explanation |
|---|---|
| npm access | Manages package access permissions. |
| npm login | Logins or creates a user. |
| npm audit | Scans for security vulnerabilities. |
| npm audit fix | Automatically fixes security vulnerabilities. |
| npm bin | Shows the directory of executable files. |
| npm bugs <paket> | Shows the error reports for the package. |
| npm completion | Provides auto-completion support for npm commands in the terminal. |
| npm dedupe | Cleans duplicate dependencies. |
| npm deprecate | Removes packages. |
| npm diff | Shows the difference between two packages. |
| npm dist-tag | Manages package tags. |
| npm docs <package> | Opens the package documentation. |
| npm edit | Opens the package for editing. |
| npm explore <package> | It goes into the package directory. |
| npm fund | Shows support information for dependencies. |
| npm hook | Manages webhook operations. |
| npm link | Creates a symbolic link for local development. |
| npm pack | Creates a package archive (.tgz) file. |
| npm ping | Tests registry connectivity. |
| npm prefix | Shows the project root directory. |
| npm profile | Manages the user profile. |
| npm prune | Removes unnecessary packages. |
| npm publish | Publishes the package. |
| npm root | Shows the node_modules directory. |
| npm search <key> | Searchs for packages. |
| npm view <package> | Shows package information. |
| npm whoami | Shows the logged-in user. |
Vue.js / Vite Commands
You can use the following commands to quickly start and develop projects with Vue.js and Vite:
| Command | Explanation |
|---|---|
| npm create vue@latest | Creates a new Vue 3 project (Vite-based). |
| npx create-vue@latest | Alternative Vue project creation command. |
| npm install -g @vue/cli | Install Vue CLI globally. |
| vue create [project-name] | Starts a new project with Vue CLI. |
| vue ui | Opens a graphical interface for Vue CLI. |
| npm run dev | Starts a Vue project in development mode. |
| npm run build | Creates the production build. |
| npm run preview | Previews the production build. |
| npm run lint | Checks the code. |
| npm install vue-router | Adds a routing system. |
| npm install pinia | Adds a state management library. |
| npm install axios | Adds Axios for API requests. |
| npm install bootstrap | Adds the Bootstrap CSS framework. |
| npm install @vitejs/plugin-vue | Installs the Vue plugin for Vite. |
| npm run serve | Starts the application in older Vue CLI projects. |
| npx vite | Runs the Vite project. |