Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Scotch.io - Create a CRUD App with Node and MongoDB 1 Getting Started

// 0)create a repo of your project folder in github first
// 1)in your folder open git bash
npm init
// 2)leave description,test command,keywords,author as empty
// 3)But name entry point as
server.js
// 4)go to github and copy url of repo and use that for github repository
URL.git// URL is copied from github
// 5) install Express
npm install --save express
// 5)open your project folder in vs code
// 6)in opened folder create new file server.js with below exact code:

// grab our dependencies
const express = require('express'),
app = express(),
port = process.env.PORT || 8080;

// configure our application

// set the routes
app.get('/', (req, res) => {
res.send('Hello, I am the app!');
});

// start our server
app.listen(port, () => {
console.log(`App listening on http://localhost: ${port}`);
});

// 7)install server(just once run this command not again)
npm install -g nodemon
// 8)Run server 
nodemon server.js

****************************
"Hello, I am the app!" should be there on localhost 8080 by now!
 
PREVIOUS NEXT
Tagged: #Create #CRUD #App #Node #MongoDB #Getting #Started
ADD COMMENT
Topic
Name
3+9 =