Sometimes, when you are picking up a new piece of tech it’s hard to get started in it, since some of the things can be quite different to what you are used. The following article and the one that will follow are meant to provide as straightforward solutions as possible, with Github code examples that you can download. All the code example will try to reference the versions or most up to date versions as possible. If you notice an outdated version do feel free to fire up an issue on Github or submit a PR with a fix on it. However for this one there won’t be Github example since it’s really basic, and it’s good to know by heart how to make the simplest of Node.js configs.
Introduction to basic installation of newest Node.JS and Express:
1.) Install Node.JS. Go to: https://nodejs.org/en/ and choose 9.1.0 or the latest Current version. After downloads finishes Install it and just follow the instructions.
2.) Go to your desired project folder and write following commands:
For creation of your project folder and cd-ing into it.
This will initialize your package.json. Follow the questions and fill out the info
3.) When getting prompted for entry point, write index.js instead.
4.) After you finish the init, add express to the list of dependencies:
npm install express --save
5.) In index.js file that you pointed to, and created it, add the following:
const express = require('express')
const app = express()
app.get(‘/’, (req, res) => res.send(‘Hello World!’))
app.listen(3000, () => console.log(‘Example app listening on port 3000!’))
After following all the previous steps
and go to http://localhost:3000/
At this point your local machine should have the server setup and running on the above url. You should see a Hello world displaying back at you.