Then download Node and select your version by running:
source~/.bashrc# source your bashrc/zshrc to add nvm to PATHcommand-vnvm# check the nvm use messagenvminstallnode# install most recent Node stable versionnvmls# list installed Node versionnvmusenode# use stable as current versionnvmls-remote# list all the Node versions you can installnvmaliasdefaultnode# set the installed stable version as the default Node
Make sure you have set the default alias for nvm - e.g.: nvm alias default 8.11.2
Add nvm-auto to your plugins in ~/.zshrc.
Add a call to the nvm_auto_switch function after NVM is initialized in your .zshrc file.
Source .zshrc in your current shell or restart your shell.
npm usage
To install a package:
To install a package and save it in your project's package.json file:
To see what's installed:
To find outdated packages:
To upgrade all or a particular package:
To uninstall a package:
npm-link
Symlink a package folder:
Yarn
For project with a lot of dependencies, or particular dependencies, we should probably use yarn.
Homebrew
You can install Yarn through the Homebrew. This will also install Node.js if it is not already installed.
If you use nvm or similar, you should exclude installing Node.js so that nvm’s version of Node.js is used.
Path Setup
If you chose manual installation, the following steps will add Yarn to path variable and run it from anywhere.
Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.
Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
In the terminal, log in and log out for the changes to take effect
To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile.
Upgrade Yarn
Yarn will warn you if a new version is available. To upgrade Yarn, you can do so with Homebrew.
Test that Yarn is installed by running:
Problems? If you are unable to install Yarn with any of these installers, please search through GitHub for an existing issue or open a new one.