在终端通过命令行安装node详细步骤

下方截图是mac电脑,从左到右第十个图标是终端图标,第一步:点击终端,打开

第二步:输入

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash

会加载下方代码,不报错:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7750  100  7750    0     0  11660      0 --:--:-- --:--:-- --:--:-- 11671
=> Downloading nvm from git to '/Users/zzk/.nvm'
=> Cloning into '/Users/zzk/.nvm'...
remote: Counting objects: 7039, done.
remote: Total 7039 (delta 0), reused 0 (delta 0), pack-reused 7039
Receiving objects: 100% (7039/7039), 2.14 MiB | 398.00 KiB/s, done.
Resolving deltas: 100% (4415/4415), done.
* (HEAD detached at v0.30.2)
  master

=> Appending source string to /Users/zzk/.bashrc
=> Close and reopen your terminal to start using nvm

第三步:输入

cat ~/.bashrc

会加载下方代码,不报错:

PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h\[\e[35;40m\]\W\[\e[0m\]]\\$ "

alias ll='ls -l'

export NVM_DIR="/Users/zzk/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
[zzk@zzkdeMacBook-Proreact学习项目练习]$ echo 'export NVM_DIR="$HOME/.nvm"
> [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc

第四步:输入

source ~/.bashrc

第五步:跟着第四部输入

nvm is

会加载下方代码,不报错:

Node Version Manager

Note: <version> 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`

Usage:
  nvm help                                  Show this message
  nvm --version                             Print out the latest released versionof 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>
  nvm uninstall <version>                   Uninstall a version
  nvm use [--silent] <version>              Modify PATH to use <version>. Uses .nvmrc if available
  nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nvmrc if available
  nvm run [--silent] <version> [<args>]     Run `node` on <version> with <args> as arguments. Uses .nvmrc if available
  nvm current                               Display currently activated version
  nvm ls                                    List installed versions
  nvm ls <version>                          List versions matching a given description
  nvm ls-remote                             List remote versions available for install
  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
  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>
  nvm reinstall-packages <version>          Reinstall global `npm` packages contained in <version> to current version
  nvm unload                                Unload `nvm` from shell
  nvm which [<version>]                     Display path to installed node version. Uses .nvmrc if available

Example:
  nvm install v0.10.32                  Install a specific version number
  nvm use 0.10                          Use the latest available 0.10.x release
  nvm run 0.10.32 app.js                Run app.js using node v0.10.32
  nvm exec 0.10.32 node app.js          Run `node app.js` with the PATH pointing to node v0.10.32
  nvm alias default 0.10.32             Set default node version on a shell

Note:
  to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)

第六步:输入

nvm install stable

会加载下方代码,不报错:

Downloading https://nodejs.org/dist/v10.1.0/node-v10.1.0-darwin-x64.tar.xz...
##                                                                         3.2%^C
Binary download failed, trying source.
####                                                                       5.8%^C
Binary download failed, trying source.
Detected that you have 4 CPU thread(s)
Set the number of jobs to 4 - 1 = 3 jobs to speed up the build
Installing node v1.0 and greater from source is not currently supported

第七步:输入

nvm install v8.9.4

会加载下方代码,不报错:

Downloading https://nodejs.org/dist/v8.9.4/node-v8.9.4-darwin-x64.tar.xz...
######################################################################## 100.0%
WARNING: checksums are currently disabled for node.js v4.0 and later
Now using node v8.9.4 (npm v5.6.0)

第八步:输入

node -v

就会出现版本号了!!!安装成功

v8.9.4






猜你喜欢

转载自blog.csdn.net/shirleyqdd/article/details/80342082