node学习之路01——不同操作系统下Node.js环境搭建

2018-01-26 10:32:05来源:segmentfault作者:Karuru人点击

分享

[TOC]
介绍

这是一个基本的Node.js环境搭建,不同的操作系统可以选择不同的安装方式
如果不需要太多的安装步骤,就直接在Node.js官网下载最新版安装包进行安装即可1. Linux环境配置

常用的软件安装


1.1 Ubuntu
sudo apt-get install git vim openssl build-essential libssh-dev wget curl
1.2 CentOS更改yum源与更新系统
首先备份/etc/yum.repos.d/CentOS-Base.repocd /etc/yum.repos.d/
下载163的yum源配置文件wget http://mirrors.163.com/.help/CentOS6-Base-163.repo运行yum makecache生成缓存yum makecache更新系统yum -y update
2. Node安装(使用NVM)curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm use node
nvm install <Node版本号>
下载淘宝镜像cnpmnpm install -g cnpm --registry=https://registry.npm.taobao.org
3. Sublime安装

安装时不需关心每条命令具体的作用,直接输入命令就好


3.1 Debian/Ubuntu使用APT安装wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text3.2 CentOS使用Yum安装sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
sudo yum-config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
sudo yum install sublime-text4. MongoDB安装v3.64.1 Ubuntu安装(目前安装步骤有问题,可能会失败)sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
Ubuntu 12.04:echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.listUbuntu 14.04:echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.listUbuntu 16.04:echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.listsudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y mongodb-org=3.6.1 mongodb-org-server=3.6.1 mongodb-org-shell=3.6.1 mongodb-org-mongos=3.6.1 mongodb-org-tools=3.6.1
sudo service mongod start4.2 CentOS安装
在/etc/yum.repos.d/mongodb-org-3.6.repo文件下输入一下内容
[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.ascsudo yum install -y mongodb-org
sudo yum install -y mongodb-org-3.6.1 mongodb-org-server-3.6.1 mongodb-org-shell-3.6.1 mongodb-org-mongos-3.6.1 mongodb-org-tools-3.6.1
sudo service mongod start4.3 Windows安装从官网下载安装包进行安装,安装目录为F:/software/MongoDB/创建data目录,在data目录下创建db和log两个目录
进入F:/software/MongoDB/bin目录,F:/software/MongoDB/bin>mongod --dbpath F:/software/MongoDB/data/db进入刚创建的log目录,创建mongodb.log文件
进入F:/software/MongoDB/目录,创建mongodb.config配置文件dbpath=F:/software/MongoDB/data/db
logpath=F:/software/MongoDB/data/log/mongodb.log
利用管理员身份打开命令行,输入mongod --config F:/software/MongoDB/mongodb.config --install --serviceName "MongoDB"5. Yarn安装
yarn config set registry https://registry.npm/taobao.org
5.1 Debian/Ubuntucurl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn5.2 CentOS/Fedora/RHELsudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum install yarn6. git的使用方法生成ssh命令ssh-keygen -t rsa -C "yourmail@mail.com"配置本地git用户名:git config --global user.name "USERNAME"配置本地git邮箱:git config --global user.email "yourmail@mail.com"安装git:yum install git-core把修改过文件存储到暂存区:git add .查看仓库文件状态:git status提交:git commit -m "some messages"移出远程origin分支:git remote rm origin将提交的内容推送到远程分支:git push origin master同步本地的master分支代码:git pull origin master,
查看本地分支git branch -a查看远程分支git branch -r创建本地分支git branch <branchName>切换分支git checkout <branchName>将本地分支push到远程分支git push origin <localBranchName>:<remoteBranchName>,只写这一条命令,表示创建一个远程分支

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台