How to upgrade Node version on Mac.
Conditions:
After I inputted vue command (vue-cli), I got the error message:
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
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.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.
Please upgrade your Node version.
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(2) Check if I used Homebrew to install Node.js
# zsh: command not found: nvm
brew upgrade node(3) Check if I used N to install Node.js
# Error: node not installed
n(4) Check if I used MacPorts to install Node.js
# zsh: command not found: n
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
3. Check the current status before upgrade Node version
(1) Current version of Node
4. Check the version of Node after installation
References
Logo of Node.js was downloaded from File:Node.js logo.svg - Wikimedia Commons
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(2) Current installed path of Node
# v8.0.0
which node
# /usr/local/bin/node
4. Check the version of Node after installation
node -v5. Now I can input vue command
# v8.12.0
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
- 4 ways to update to the latest Node.js version on a Mac other installation approach
- How to Uninstall Node.js from Mac OSX
- javascript - How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) - Stack Overflow
- Mac删除nodejs的方法 | 群峰之下
Logo of Node.js was downloaded from File:Node.js logo.svg - Wikimedia Commons
留言
張貼留言