Prerequisits
node.js installednpm installed
Install express globaly
$ npm install -g expressCreate a npm project
Create your project rootfolder "express-project" and open a terminal in that folder and typpe:$ npm init
Follow the intstructions on your terminal.
Add needed dependencies
Open package.json and add your dependencies. My package.json looks like that:You can just pick the "dependencies" object
Add you dependencies
Create a file "app.js" and paste following codeThis will reference your dependencies and setup your express webserver.
As you can see, the webserver will be bound on port 3000 and it will return a simple "Hello world" response and will log the same words to the console.
Start the webserver
Open a terminal in the projectroot and type:$ node app.js
Now you can surf http://localhost:3000 and you should see "Hello world"
Thats it
Keine Kommentare:
Kommentar veröffentlichen