Příspěvky

Installing NodeJS on Linux

FIrst step: install node on your server, the node package manager is already included (npm) curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt install -y nodejs   Install yarn package manager - caches downloads   sudo apt install yarn   Node installed, let's head over to build our first web server! Inside an app.js file:   // node server config const http = require('http'); // localhost - IP loopback connection to my machine - for now // since I don't have port forwarding setup yet const hostname = '127.0.0.1'; // default port for NodeJS: 3000 const port = '3000'; // http.createServer([options][, requestListener] // requestListener is a function // return an instance of http.server const server = http.createServer((req, res) => { // HTTP status code 200 = OK res.statusCode = 200; // setting the HTML header - metadata res.setHeader('Content-Type', 'text/plain'); // signal that all

20 Cool Things You Can Do With Gulp

Obrázek
What is Gulp? Tool for building javascript applications Front end build system Built on NodeJS Common Gulp tasks get rid of whitespaces in scripts therefore save space concatenate files therefore save space let browser know if there's a new version of a cached file testing linting optimization also a web server plugin to run code on a development server  How Gulp exactly works built on Node streams streams - flow of data that can be manipulated asynchronously files are linked through pipelines - the pipe() operator output of one file is the input of another - run task after task maybe linking different plugins for example  the files are not affected until all the plugins had been processed Gulp is based on streams and javascript code  Configuring Gulp 1) Install Gulp globally - access to it anywhere on your system npm install -g gulp 2) Create the directory for your project  mkdir exampleProject   3) cd into the directory and open i