How to upgrade Node version on Mac

How to upgrade Node version on Mac.

Logo of Node.js (trademark policy)


Conditions:

After I inputted vue command (vue-cli), I got the error message:
You are using Node v8.0.0, but this version of vue-cli requires Node >=8.9.
Please upgrade your Node version.
I forgot how to install Node.js on my Mac. I use Homebrew to upgrade Node.js but it installed at different location (/usr/local/Cellar/node/10.12.0). Current Node.js was installed at /usr/local/bin/node . After installed the new version of Node.js by HomeBrew, I got the same error message again.

Solution:

1. Because I forgot how to install Node.js on my Mac. Based on the article 4 ways to update to the latest Node.js version on a Mac, I tried to find out my way.

(1) Check if I used NVM (Node Version Manager) to install Node.js
nvm
# zsh: command not found: nvm 
(2) Check if I used Homebrew to install Node.js
brew upgrade node
# Error: node not installed
(3) Check if I used N to install Node.js
n
# zsh: command not found: n
(4) Check if I used MacPorts to install Node.js
port
# zsh: command not found: port

Finally, I figured out I download the Node.js installer from official website.

2. Use HomeBrew remove the installed package
brew remove node
# Uninstalling /usr/local/Cellar/node/10.12.0... (3,939 files, 46.6MB)

3. Check the current status before upgrade Node version
(1) Current version of Node
node -v
# v8.0.0
(2) Current installed path of Node
which node
# /usr/local/bin/node 

4. Check the version of Node after installation
node -v
# v8.12.0
5. Now I can input vue command
Usage: vue <command> [options]
Options:
  -V, --version                         output the version number
  -h, --help                            output usage information
Commands:
  create [options] <app-name>           create a new project powered by vue-cli-service
  add <plugin> [pluginOptions]          install a plugin and invoke its generator in an already created project
  invoke <plugin> [pluginOptions]       invoke the generator of a plugin in an already created project
  inspect [options] [paths...]          inspect the webpack config in a project with vue-cli-service
  serve [options] [entry]               serve a .js or .vue file in development mode with zero config
  build [options] [entry]               build a .js or .vue file in production mode with zero config
  ui [options]                          start and open the vue-cli ui
  init [options] <template> <app-name>  generate a project from a remote template (legacy API, requires @vue/cli-init)
  config [options] [value]              inspect and modify the config
  Run vue <command> --help for detailed usage of given command.

References
Logo material:
Logo of Node.js was downloaded from File:Node.js logo.svg - Wikimedia Commons


留言