当前系统环境centos6 64位
1.更新系统
由于这里是刚重装的纯净系统,所以需要先升级一下。

yum -y update

2.使用yum安装nodejs和npm
一般安装软件前最好更新一下,避免出现一些乱七八糟的错误。

curl --silent --location https://rpm.nodesource.com/setup_9.x | bash -
yum install nodejs -y
#验证一下
[root@YUN84231334 ~]# node -v
v9.11.2
[root@YUN84231334 ~]# npm -v
5.6.0
[root@YUN84231334 ~]# npx -v
9.7.1

运行过程:

[root@YUN84231334 ~]# curl --silent --location https://rpm.nodesource.com/setup_9.x | bash -


## Installing the NodeSource Node.js 9.x repo...




## Inspecting system...


+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m


## Confirming "el6-x86_64" is supported...


+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_9.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'


## Downloading release setup RPM...


+ mktemp
+ curl -sL -o '/tmp/tmp.wXklYZJoOZ' 'https://rpm.nodesource.com/pub_9.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'


## Installing release setup RPM...


+ rpm -i --nosignature --force '/tmp/tmp.wXklYZJoOZ'


## Cleaning up...


+ rm -f '/tmp/tmp.wXklYZJoOZ'


## Checking for existing installations...


+ rpm -qa 'node|npm' | grep -v nodesource


## Run `sudo yum install -y nodejs` to install Node.js 9.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn


[root@YUN84231334 ~]# yum install nodejs -y
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirror.keystealth.org
* extras: mirror.scalabledns.com
* updates: repos.lax.quadranet.com
nodesource                                                       | 2.5 kB     00:00     
nodesource/primary_db                                            |  27 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:9.11.2-1nodesource will be installed
--> Finished Dependency Resolution


Dependencies Resolved


========================================================================================
Package        Arch           Version                         Repository          Size
========================================================================================
Installing:
nodejs         x86_64         2:9.11.2-1nodesource            nodesource          17 M


Transaction Summary
========================================================================================
Install       1 Package(s)


Total download size: 17 M
Installed size: 51 M
Downloading Packages:
nodejs-9.11.2-1nodesource.x86_64.rpm                             |  17 MB     00:03     
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA256 Signature, key ID 34fa74dd: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
Userid : NodeSource <gpg-rpm@nodesource.com>
Package: nodesource-release-el6-1.noarch (installed)
From   : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:nodejs-9.11.2-1nodesource.x86_64                                   1/1
  Verifying  : 2:nodejs-9.11.2-1nodesource.x86_64                                   1/1


Installed:
  nodejs.x86_64 2:9.11.2-1nodesource                                                    


Complete!
[root@YUN84231334 ~]# node -v
v9.11.2
[root@YUN84231334 ~]# npm -v
5.6.0
[root@YUN84231334 ~]# npx -v
9.7.1

3.使用npx运行软件
通过npx运行,快速又方便。
具体参数如下

[root@YUN84231334 ~]# npx @nondanee/unblockneteasemusic -h
npx: installed 1 in 3.254s
usage: unblockneteasemusic [-v] [-p port] [-a address] [-u url] [-f host]
                           [-o source [source ...]] [-t token] [-e url] [-s]
                           [-h]


optional arguments:
  -v, --version                   output the version number
  -p port, --port port            specify server port
  -a address, --address address   specify server host
  -u url, --proxy-url url         request through upstream proxy
  -f host, --force-host host      force the netease server ip
  -o source [source ...], --match-order source [source ...]
                                  set priority of sources
  -t token, --token token         set up proxy authentication
  -e url, --endpoint url          replace virtual endpoint with public host
  -s, --strict                    enable proxy limitation
  -h, --help                      output usage information

直接启动或者使用上面的参数启动即可开始食用。

npx @nondanee/unblockneteasemusic



[root@YUN84231334 ~]# npx @nondanee/unblockneteasemusic
npx: installed 1 in 3.031s
HTTP Server running @ http://0.0.0.0:8080