Skip to content

NPM & Terminal

kitiya edited this page Jun 21, 2020 · 3 revisions

NPM

Set up a new or existing npm package

npm init

Find the version of an installed npm package

npm list for local packages or npm list -g for globally installed packages.

npm list            // for local packages
npm list -g         // for global packages
npm list --depth=0  // view packages without their dependencies

TERMINAL

MAC Terminal Commands Cheat Sheet

Shortcuts

COMMAND DESC
Tab Auto-complete file and folder names
Ctrl + A Go to the beginning of the line you're currently typing on
Ctrl + E Go to the end of the line you're currently typing on
Ctrl + L Clear the screen
Ctrl + C Kill whatever you're running
Ctrl + D Exit the current shell
Option + → Move cursor one word forward
Option + ← Move cursor one word backward
Ctrl + _ Undo the last command

Basics

COMMAND DESC
/ (Forward Slash) Top level directory
. (Single Period) Current directory
.. (Double Period) Parent directory
~ (Tilde) Home directory
sudo [command] Run command with the security privileges of the super user
nano [file] Opens the Terminal editor
open [file] Opens a file
[command] -h Get help about a command
man [command] Show the help manual of the command

ZTM

  • ls

  • pwd

  • cd

  • cd..

  • clear

  • cd /

  • cd ~

  • cd <folder/folder/folder>

  • mkdir <folder>

  • open <folder>

  • touch index.html

  • open index.html

  • open -a "Sublime Text" index.html

  • rm <file>

  • rm -r <folder>

Troubleshooting

zsh: command not found

Overview

  • zsh: command not found after moving over to zsh following the Catalina upgrade
  • Got the error above when running $ nvm --version command,
  • Step 1 - the ~/.zshrc file need add some config:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

  • Step 2 - Run the command below:
$ source ~/.zshrc

Note: GitHub: NVM

Clone this wiki locally