Whether npm or other front-ent package manager tools are all writtent by node, therefor, if we want to use it, we should install node at first.
https://nodejs.org/en/
After installing node, we will get npm to manage your javascript packages.
As we all know, npm is a package manager for JavaScript and word's largest software register. Recently, I found a tool like npm and more stronger than npm on mac system, that is Hombrew. So maybe you will ask what's the difference between npm and homebrew
- Difference between homebrew and npm
This is a rough, inaccurate answer, but it’s very easy to understand and it can give you a quick preview: Homebrew is like the Mac App Store: it installs softwares that can be used in the whole system. npm is like the Extension manager in Chrome: it can only add function extensions within a single app.
- Installation
$ npm install homebrew
For now, maybe you want to install different node version on one operating system, then "nvm" will help you solve this problem.
https://github.com/creationix/nvm/blob/master/README.md
you can use bellow command to check node version or other nvm commands
nvm --help Usage: nvm --help Show this message nvm --version Print out the installed version of nvm nvm install [-s] <version> Download and install a <version>, [-s] from source. Uses .nvmrc if available --reinstall-packages-from=<version> When installing, reinstall packages installed in <node|iojs|node version number> --lts When installing, only select from LTS (long-term support) versions --lts=<LTS name> When installing, only select from versions for a specific LTS line --skip-default-packages When installing, skip the default-packages file if it exists --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version nvm uninstall <version> Uninstall a version nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available. nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available. nvm use [--silent] <version> Modify PATH to use <version>. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm run [--silent] <version> [<args>] Run `node` on <version> with <args> as arguments. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts=<LTS name> Uses automatic alias for provided LTS line, if available. nvm current Display currently activated version nvm ls List installed versions nvm ls <version> List versions matching a given <version> nvm ls-remote List remote versions available for install --lts When listing, only show LTS (long-term support) versions nvm ls-remote <version> List remote versions available for install, matching a given <version> --lts When listing, only show LTS (long-term support) versions --lts=<LTS name> When listing, only show versions for a specific LTS line nvm version <version> Resolve the given description to a single local version nvm version-remote <version> Resolve the given description to a single remote version --lts When listing, only select from LTS (long-term support) versions --lts=<LTS name> When listing, only select from versions for a specific LTS line nvm deactivate Undo effects of `nvm` on current shell nvm alias [<pattern>] Show all aliases beginning with <pattern> nvm alias <name> <version> Set an alias named <name> pointing to <version> nvm unalias <name> Deletes the alias named <name>