Skip to content

Antoine-Flo/tuto-nodeJs

Repository files navigation

Tutoriel NodeJs

1 - Installer Node


2 - Commandes

npm init npm i -g nodemon


3 - Script NPM

"dev": "nodemon server.js"


4 - Create module

    • Créer fichier module.js

    • Ajouter :
module.exports = {
    stat: 5,
    log() {
        console.log("Le module fonctionne");
    }
}
    • Dans server.js => ajouter
const test = require('./module');
console.log(test.stat);
test.log()

5 - Global objects

__dirname
__filename
module
require()
process

4 - Serveur

Create server.js Ajouter boilerplate :

const http = require("http");

const server = http.createServer(function (req, res) {
  res.write("Hello World!");
  res.end();
});

server.listen(3000, () => {
  console.log("Server listen port 3000");
});

5 - Start serveur

npm run serv


6 - Main modules

http url querystring path fs util

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published