NodeJs sample application for beginners to learn and get familiar with different NPM modules. This project can be used as a basic architecture for any application. The plugin will contain the code required for HTML, sinle-page application and how & where to set Authorization.
The sample application is a nice way to help and guide a fresher through various basic NPM modules that are needed in almost every NodeJs application. The idea is not to spoon feed, but to guide and make them familiar with errors that they might come across and why different NPM modules are used for. This is to guide them how to find out an NPM module which better suits to their need. This also have a look and feel what an API is and how HTML interacts with NodeJs and Database and with other applications.
Issues related to application can be submitted here https://github.com/navinbisht1992/nodejs-frontend-sample/issues
- Get basic knowledge of HTML and JavaScript.
- Create a directory for logs:
//At root
mkdir logger
- npm is the package manager for JavaScript and the world’s largest software registry. Discover packages of reusable code — and assemble them in powerful new ways.
- To install nodeJs and NPM: https://nodejs.org/en/
- Node Version Manager (NVM) is used to maintain different node version in same machine.
- To install or update nvm, you can use the install script using cURL: As a matter of best practice we’ll update our packages:
apt-get update
The build-essential package should already be installed, however, we’re going still going to include it in our command for installation:
apt-get install build-essential libssl-dev
Use the following curl command to kick-off the install script:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
After running the above command, you may receive output similar to the following:
Close and reopen your terminal to start using nvm
Either do as the output suggests, and close and reopen your terminal session, or run the following command:
source ~/.profile
We can quickly verify that NVM is now installed and working properly with the following command:
nvm --version
Another very useful command to get you started on node.js management is:
nvm help
Follow instructions from nvm help
to install different node
version.
1. config
└─ 1. logger.js
2. logger
└─ 1. logger.log
3. public
├─ 1. css
| ├─ 1. app.css
| ├─ 2. bootstrap.min.css
| └─ 3. jquery-modal.min.css
├─ 2. js
| ├─ 1. addInfo.js
| ├─ 2. editInfo.js
| ├─ 3. getInfo.js
| ├─ 4. jquery-modal.min.js
| ├─ 5. jquery.min.js
| └─ 6. login.js
| └─ 7. service.js
└─ 3. logo.jpg
4. router
├─ 1. index.js
└─ 2. user.js
5. views
├─ 1. index.ejs
└─ 2. login.ejs
6. .gitignore
7. app.js
8. package.lock.json
9. package.json
- Method 1 using
node
:
node app / node app.js
- Method 2 using
npm
:
npm start
- Method 3 using
npm forever
andnpm forever-monitor
:
// Install forever
npm i forever -g
// Install forever-monitor
npm i forever-monitor
forever start app.js
- Started using method 1:
ctrl c
- Started using method 2 using:
ctrl c
- Started using method 3:
forever stop app.js