Centos Nodejs

设置Nodejs环境


第二节:Installing Node.js, PM2 and Yarn on CentOS https://www.youtube.com/watch?v=XCgCjasqEFo&list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh&index=2

官司方网站:https://nodejs.org/en/

选择其他下载

通过下载Nodejs的Package

 

下载Centos对应的版本

完整步骤

运行脚本

curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -

sudo yum -y install nodejs

 安装完成后,需要使用命令来查看nodejs和npm是否成功安装,如果可以查看到版本号,则是成功的

node -v
npm -v

 npm全局安装pm2和http-server,这个是为了测试服务器是否已经成功安装nodejs

npm install -g pm2 http-server

 创建一个index.html文件,并使用http-server启动站点

echo "hello world" > index.html
http-server

安装yarn,yarn是另一个nodejs包管理器,比npm还更受欢迎,官方网站:https://yarnpkg.com/en/docs/getting-started,点击右边的安装

运行命令

wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum install yarn

查看yarn是否安装成功运行命令

yarn --version

第三节:How to Create Non-Root User https://www.youtube.com/watch?v=LbJK48gvXcA&index=3&list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

创建一个新用户,这样就无需一直使用root用户了

#add user
adduser weschen

#update user
usermod -aG wheel weschen

#sudo su - weschen

第四节:

未完待续

原文地址:https://www.cnblogs.com/weschen/p/7494916.html