- MongoDB
- Node.js
- Command Line Tools
- Mac OS X: Xcode (or OS X 10.9 Mavericks:
xcode-select --install
) - Windows: Visual Studio
- Ubuntu:
sudo apt-get install build-essential
- Fedora:
sudo yum groupinstall "Development Tools"
- OpenSUSE:
sudo zypper install --type pattern devel_basis
Note: If you are new to Node or Express, I recommend to watch Node.js and Express 101 screencast by Alex Ford that teaches Node and Express from scratch. Alternatively, here is another great tutorial for complete beginners - Getting Started With Node.js, Express, MongoDB.
- In bash/terminal/command line,
cd
into your project directory. - Run
npm install
to install required files. - When it's done installing, run one of the task runners to get going:
gulp
manually compiles files.gulp watch
automatically compiles files when changes are made and applies changes using LiveReload.gulp test
compiles files and runs unit tests.
The easiest way to get started is to clone the repository:
cd
# SOMETIMES YOU HAVE TO START MONGOD
mongod
mongo dp
# command + t
cd NodeKeystoneMiniBoilerplate
# Install NPM dependencies
sudo npm install
nodemon start
# command + t
gulp && gulp watch
# if it crashes use
killall -9 node && nodemon start
# Wont start? try...
rm -rf node_modules
sudo npm install
# open http://localhost:3000/
Note: I highly recommend installing Nodemon.
It watches for any changes in your node.js app and automatically restarts the
server. Once installed, instead of node app.js
use nodemon app.js
. It will
save you a lot of time in the long run, because you won't need to manually
restart the server each time you make a small change in code. To install, run
sudo npm install -g nodemon
.
Dump MongoDB
mongodump
Edit the database
db.fonts.update(
{},
{ $set: { price: NumberInt(60) } },
{ multi: true }
)
Server setup
chmod 400 start.pem
ssh -i "start.pem" ubuntu@##.##.###.###
sudo apt-get install git
git init
git remote add origin https://github.com/###/###.git
git pull origin master
#ONLY IF YOU HAVE TO
#Force Git
git fetch --all
git reset --hard origin/master
#restore DB
sudo apt-get install mongodb-clients
sudo apt-get install mongodb-server
mongo start --eval "db.dropDatabase()"
mongorestore
#install npm
#sudo apt-get update
sudo apt-get install npm
sudo apt-get install nodejs-legacy
sudo npm install
# WAIT 4 EVERS... X_X
#set ENV variables
mv SERVER.env .env
#start the app
sudo npm -g install forever
ps aux | grep forever
sudo npm install
forever start start.js
check http://##.##.###.###:3000/