In this tutorial we will learn how to install NPM(https://www.npmjs.com/) and use NPM packages. NPM is by far one of the largest package manager out there, NPM has over 240.000 packages available, free for everyone.
How to use packages from npm:
- after you have installed them via `npm install package-name` you are able to use them with require('package-name')
you can use packages if you require them, lets assume we have a `index.js` in the same directory as the `package.json` and you have `express` installed as a dependency, your `index.js` could look something like this:
// here is how we use an npm package with require
var express = require('express');
// here we use this package, read the docs of this package
var app = express();
// create a route, something express specific
app.get('/', function (req, res) {
res.send('Hello, World');
});
// create the server listen to port 3000, something express specific
app.listen(3000);
If you know execute this file, e.g. `node index.js` you can visit localhost:3000 in your browser and it will respond with 'Hello, World'...
You can use all packages with require('packagename'). If you want to know how to use a specific package, search for it on npm or github and read the docs.
---
Make sure to check out their websites:
Node.js - https://www.nodejs.org/
NPM - https://www.npmjs.com/
Express - https://www.expressjs.com/
Bootstrap - https://www.getbootstrap.com/
---
Follow me on github - https://www.github.com/aichbauer
Follow me on Twitter - https://twitter.com/laichbauer