Initiate package.json and install dependencies - ultimagriever/mean-apz GitHub Wiki
Install Node.js
If you don't have Node.js and NPM installed in your machine, here are instructions on how to install it.
Windows
Download the package at https://nodejs.org/en/download/. NPM comes bundled with it.
Mac OS X
Install Node.js via Homebrew. NPM comes bundled with it. brew install node
Linux
Install Node.js via your package manager (yum, apt)
Arch Linux
pacman -S nodejs npm
Ubuntu/Debian-based distros
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
RHEL / Fedora / CentOS
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
yum -y install nodejs
FreeBSD / OpenBSD
Install Node.js via the port system.
cd /usr/ports/www/node-devel/ && make install clean
Or via package manager.
pkg install node-devel
Initiate NPM
npm init
Running npm init
will create a package.json
file in your application root. This file will keep record of your application dependencies, as well as document application metadata, such as name, version, keywords and main (entry) file. The dependencies will be stored in a folder called node_modules
.
Edit your package.json file
vi package.json
Replace the contents of your package.json
with the contents below.
{
"name": "mean-apz",
"version": "1.0.0",
"description": "The complete guide to creating a MEAN app from a to z",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"mongodb": "^2.2.1",
"dotenv": "^2.0.0"
}
}
Save (:wq
) then run
npm install
This will install all the packages listed under "dependencies"
to a folder called node_modules
.
On to our next step: Set up your Express server and routes