Category: JavaScript

Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html” in Nginx when deploying an Angular application

Failed to load module script: The server responded with a non-JavaScript MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec. This happens in Google Chrome and any modern browser that supports JavaScript modules. For example when “building” the Angular 8+ app, this file is usually generated, that is […]

Read More

What is a namespace in JavaScript?

There was a time when we didn’t have the power of ES2015 JavaScript modules to create applications; so, we had to invent a system to keep our code well-organized, avoid collisions in names, share functions among JavaScript blocks or files, etc. that is when the concept of namespace came into play in the JavaScript world. […]

Read More

What is semantic versioning?

Have you seen how a project like Angular is versioned? You have maybe noticed when a brand-new release of that framework is created they release  it with three numbers, e. g. Angular 5.0.0, now the question is: what those three digits mean? The answer is simple: they are using a system called Semantic Versioning or mostly […]

Read More

How to set moment.js timezone when creating a date

The Problem Since Moment.js is a library that runs client-side, when you create a new date using it; the constructor will take the current user’s timezone. This is not convenient when you want to display a list of dates that don’t depend on the user’s browser. Let’s see an example of this, imagine you have […]

Read More

Learning Functional Programming with JavaScript – JSUnconf 2016

Functional Programming? Oh yeah, that is one of the most interesting paradigms in computer sciences that is being used since a long time ago, however in the last years it has obtained a particular interest because of JavaScript, in fact, I bet you are being using functional programming without even know it. In this great conference […]

Read More

Logging detailed error messages when running Gulp.js tasks

Gulp.js has become one of the most used task managers nowadays. But sometimes, when running several tasks with many pipes( ) on them, it is very difficult to understand what’s wrong or the actual reason why our task is not working as expected. For others like me, who like to have a better error description, here is what needed to do: Install Gulp Util npm […]

Read More

Getting started with Gulp.js from scratch

Let’s talk and think… So, you are a front-end developer, right? Don’t you think we should optimize our repetitive tasks as much as possible? Well, I have good news for you; nowadays we have a vast amount of tools that make our life easier and happier… you don’t believe me, right? Continue reading then… When […]

Read More

How to list the Node.js packages that are installed as globals

This is probable one of the simplest commands that NPM has; it is just to get the whole list of packages that we have installed as global. npm -g ls –depth=0 The output should look like this: /usr/local/lib ├── bower@1.5.3 ├── bufferstreams@0.0.2 ├── clean-css@2.1.8 ├── clone@0.1.11 ├── connect@2.24.3 ├── doctoc@0.7.1 ├── event-stream@3.1.2 ├── git-changelog@0.1.1 ├── […]

Read More

How to get the keyboard key value with jQuery and run a custom action

This is probably the simplest way to capture the key that the user pressed and execute an action (in this case just a simple console.info). (function() { function customAction() { console.info(“You have pressed an ‘a’ in your keyboard”); } $(window).on(‘keypress’, function(event) { console.log(event.keyCode); // keyCode te da el código de la tecla que presiones if (event.keyCode […]

Read More