It a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
🔑 The read function accepts an expression from the user, and parses it into a data .For example 2+3
🔑 The eval function takes this internal data structure and evaluates it. function + is called on the arguments 2 and 3, yielding the result 5.
🔑 The print function takes the result yielded by eval, and prints it out to the user. If it is a complex expression, it may be pretty-printed to make it easier to understand
🔑 The development environment then returns to the read state, creating a loop, which terminates when the program is closed.
>$ node
> 2 + 3
5
> console.log(‘hello world’)
Hello world
>
🍄 Express.js is free 🆓 open source web application frameworks for node.js .
🍄 It is used for designing and building web application 💻 .
🍄 It is used to build both static and dynamic web pages.
🍄 click me to know more about express.js
Step1 : you need to install express in your node as it is not a core module.
npm i [email protected]
💊 now the version 4.16.4 is installed in node.js
step2 : then ,code your program as
const app = express()
app.get(‘’,(req,res)=>{
res.send(‘hello world!’)
})
app.listen(4000,()=>{
console.log(‘the port 4000 is running’)
})
Step3 : Now go to the browser and enter the URL
http://localhost:4000 to see your output.
- The get() function has a path name and a callback fuction with 2 arguments namely req-request and res-response.
- The send() function is used to display it to the user.Here both HTML or JSON can be used to send
res.send(‘ <h1> hello world </h1> ’)
res.send({
Name:’catherine’,
Location:’chennai’
})
💡 Core module operate at lower level. They are inbuilt with node.js . So, there is no need to install separately like we do to install nodemon and request in NPM
💡 click me to know more about node core modules
module | use |
---|---|
fs | to work with file I/O |
http | to create Node.js http server |
path | to deal with file paths |
querystring | to deal with query string |
const module = require('module_name');
💊 core modules are complex compared to third-party modules,but anyway you don't need internet to install like third-party module