#NodeJS Template for new NodeJS Server Project This project can be used as a starting point for a NodeJS Server. It uses NodeJS, Express, Gulp and various tools for building (Gulp), Static Code Checking (eslint), Unit Testing (mocha,supertest)
To get this project working from a virgin Windows Machine perform the following steps: ##Install Node.JS - Go to https://nodejs.org/en/download/ and download the appropriate version for the Windows Version (32/64 bit) This app has been tested with Node JS Version v6.6.0. Though for current development projects I'm "forced" to use Node JS Version V4.x :( .
Open a command prompt (I'd recommend installing ConsoleZ )
- Create an environmental variable called NODE_PATH
- Set it to: %AppData%\npm\node_modules
- Close CMD, and Re-Open to get the new ENV variables
##Install Dependencies
From the command prompt (in the project folder) use npm to install the project dependencies:
C:\My_New_Project>npm install
##Run gulp From the command prompt (in the project folder) use npm to run the gulp command C:\My_New_Project>npm run gulp
You can use npm run
to find a list of other tasks to run, such as npm start
which spins up the server or npm run lint
to run the code linter.
##Execute various tasks
[14:19:04] Using gulpfile C:\My_New_Project\gulpfile.js
[14:19:04] Starting 'default'...
? Select the action to perform (Use arrow keys)
Lint - Perform lint check on source code
Build - Remove all console logging and push modified source to dist folder
Post - Prompt for info and issue POST passing binary data to OMA Server
PostND - Simple post with NO data to OMA Server
Get - Issue a simple get to the OMA server
Test - Run mocha test scripts
Forever - Launch the server, restart if src files change
In order to run the Post, PostND, Get tasks the Server must be launched in a separate command window via the "gulp forever" task.