Mac下卸载和 安装node

卸载node

sudo npm uninstall npm -g sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* sudo rm -rf /usr/local/include/node /Users/$USER/.npm sudo rm /usr/local/bin/node sudo rm /usr/local/share/man/man1/node.1 sudo rm /usr/local/lib/dtrace/node.d

验证是否卸载成功

node -v

npm -v



安装node

首先安装nvm(node.js version management)

open Terminal 

 vi   .bash_profile

将下面内容拷贝到bash_profile文件中

source ~/.bashrc 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

关闭并保存bash_profile文件,执行

source .bash_profile

验证:

nvm

Node Version Manager (v0.35.2) Note: refers to any version-like string nvm understands. This includes: - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1) - default (built-in) aliases: node, stable, unstable, iojs, system - custom aliases you define with `nvm alias foo` Any options that produce colorized output should respect the `--no-colors` option. Usage: nvm --help Show this message nvm --version Print out the installed version of nvm nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available --reinstall-packages-from= When installing, reinstall packages installed in --lts When installing, only select from LTS (long-term support) versions --lts= 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 --no-progress Disable the progress bar on any downloads nvm uninstall Uninstall a version nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available. nvm uninstall --lts= Uninstall using automatic alias for provided LTS line, if available. nvm use [--silent] Modify PATH to use . Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts= Uses automatic alias for provided LTS line, if available. nvm exec [--silent] [] Run on . Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts= Uses automatic alias for provided LTS line, if available. nvm run [--silent] [] Run `node` on with as arguments. Uses .nvmrc if available --lts Uses automatic LTS (long-term support) alias `lts/*`, if available. --lts= Uses automatic alias for provided LTS line, if available. nvm current Display currently activated version of Node nvm ls [] List installed versions, matching a given if provided --no-colors Suppress colored output --no-alias Suppress `nvm alias` output nvm ls-remote [] List remote versions available for install, matching a given if provided --lts When listing, only show LTS (long-term support) versions --lts= When listing, only show versions for a specific LTS line --no-colors Suppress colored output nvm version Resolve the given description to a single local version nvm version-remote Resolve the given description to a single remote version --lts When listing, only select from LTS (long-term support) versions --lts= When listing, only select from versions for a specific LTS line nvm deactivate Undo effects of `nvm` on current shell nvm alias [] Show all aliases beginning with --no-colors Suppress colored output nvm alias Set an alias named pointing to nvm unalias Deletes the alias named nvm install-latest-npm Attempt to upgrade to the latest working `npm` on the current node version nvm reinstall-packages Reinstall global `npm` packages contained in to current version nvm unload Unload `nvm` from shell nvm which [current | ] Display path to installed node version. Uses .nvmrc if available nvm cache dir Display path to the cache directory for nvm nvm cache clear Empty cache directory for nvm Example: nvm install 8.0.0 Install a specific version number nvm use 8.0 Use the latest available 8.0.x release nvm run 6.10.3 app.js Run app.js using node 6.10.3 nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3 nvm alias default 8.1.0 Set default node version on a shell nvm alias default node Always default to the latest available node version on a shell Note: to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)

你可能感兴趣的:(Mac下卸载和 安装node)