1.Install Ubuntu16:20.122 ubuntu/test123
2.install software
sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
node -v
因为国内的网络环境,直接从npm官方源安装软件包速度会比较慢,甚至导致安装不成功。
我们可以安装nrm工具,用于管理软件源。
sudo npm install -g nrm
nrm ls
nrm use taobao
3.start server
sudo npm install -g @angular/cli
#sudo git config --global user.email [email protected];git config --global user.name will;
ng new project
在Ubuntu18上安装node后发现版本过低,解决如下:
15 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
17 nvm ls-remote
18 sudo nvm install v10.16.0
QK:~/Pan$ node -v
v10.16.0
QK:~/Pan$ npm -v
6.9.0
############项目相关
创建:ng new project
启动:ng serve --host 0.0.0.0
项目迁移:
重要的是把package.json记下来,否则新安装的包可能和原有代码或其他包会冲突。例如:
npm uninstall --save @angular/material
npm install --save @angular/[email protected]
后端及MongoDB:
mkdir backend
cd backend
npm init -y
npm install --save-dev babel-cli babel-preset-env
vi .babelrc
{
"presets": ["env"]
}
Later on, To start:
npm run dev
##
npm install express
npm install mongoos(install mongodb first)
Mongodb:(U18)
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
1.sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
2.echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
3.sudo apt-get update
4.sudo apt-get install -y mongodb-org (更换国内源安装,见下)
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
sudo service mongod start
log:/var/log/mongodb/mongod.log
##安装太慢,更换U18国内源:
mv /etc/apt/sources.list /etc/apt/sourses.list.backup
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
瞬间装好.
其他命令:
sudo apt-get update 更新源 sudo apt-get install package 安装包 sudo apt-get remove package 删除包 sudo apt-cache search package 搜索软件包 sudo apt-cache show package 获取包的相关信息,如说明、大小、版本等 sudo apt-get install package --reinstall 重新安装包 sudo apt-get -f install 修复安装 sudo apt-get remove package --purge 删除包,包括配置文件等 sudo apt-get build-dep package 安装相关的编译环境 sudo apt-get upgrade 更新已安装的包 sudo apt-get dist-upgrade 升级系统 sudo apt-cache depends package 了解使用该包依赖那些包 sudo apt-cache rdepends package 查看该包被哪些包依赖 sudo apt-get source package 下载该包的源代码 sudo apt-get clean && sudo apt-get autoclean 清理无用的包 sudo apt-get check 检查是否有损坏的依赖
sudo mkdir -p /data/db
sudo chown [username] /data/db
sudo service mongod start
sudo tail -f /var/log/mongodb/mongod.log
继续安装:
npm install express
npm install mongoos
导入之前的数据库:
~/backend_$ mongo
> show dbs
> use mat;
switched to db ma
> show collections;
dump整个数据库:
mongodump -h localhost:27017 -d mat -o mat
导入新环境: mongorestore -h localhost:27017 -d mat --dir mat
运行后端:
npm run dev