Run On Localhost
THIS TOOK ME FOREVER TO FIGURE OUT, SO I WANT TO HELP PEOPLE TO FIGURE OUT
THIS A WINDOWS TUTORIAL, BUT YOU CAN TRY IT ON YOUR DEVICE, (no promises) AND NODE JS DOESN'T WORK ON ANDROID/MOBILE
First, create a folder in documents called javascript
Next, go download node js here
Then, create a file called 'index.js' while node js is downloading.
Then, put some Express stuff in index.js
const express = require('express')
const app = express()
const port = 8080
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
Then, !!!!save!!!! (don't forget to save)
Then, go to [node command prompt] and type in npm init
, that will lead you throught a series of steps to create a package.json.
Then, type in npm install express
Then, type in cd documents
, then cd javascript
, then node "myfirst.js"
(with the quotes!!!), now, it should log Example app listening at http://localhost:8080.
last part: go to your browser and go to this link and you have sucessfuly built a node js app.