internet fundamentals and scripting subject Write steps for creating following program. 1. How we create an npm project and mention the package needed to install express.js globally. 2. Now write code to create an express.js app which funnels the requests through 2 middleware functions that log something to the console and return one response. 3. Handle the requests to "/" and "/shop" and “/users” such that each request only has one handler /middleware that does something with it
internet fundamentals and scripting subject
Write steps for creating following program.
1. How we create an npm project and mention the package needed to install express.js globally.
2. Now write code to create an express.js app which funnels the requests through 2 middleware functions that log something to the console and return one response.
3. Handle the requests to "/" and "/shop" and “/users” such that each request only
has one handler /middleware that does something with it
1.
Create a directory to contain your application and make it your working directory, assuming you've previously installed Node.js.
$mkdir myapp
$cd myapp
Create a package.json file for your application with the npm init command. See Specifics of npm's package.json handling for additional information on how package.json works.
$ npm init
This command will ask you for information such as your application's name and version. With the exception of the following, you may just hit RETURN to accept the defaults for the time being:
entry point: (index.js)
Enter app.js, or whatever name you choose for the main file. If index.js is what you want, press RETURN to accept the proposed default file name.
Now, under the myapp directory, install Express and save it in the requirements list. Consider the following scenario:
$ npm install express --save
To temporarily install Express without adding it to the requirements list, follow these steps:
$ npm install express --no-save
Step by step
Solved in 3 steps with 10 images