Tag Archives: node.js

Gulp vs Grunt

Gulp and Grunt are JavaScript task runners, I will assume you already have an understanding of what they do and your just looking for a reason to use one or the other.

In all honesty I haven’t spent more than a week or so in terms of man hours working with either Grunt or Gulp. But to me Gulp feels like the better option.

Why Gulp?

Switching to Gulp from Grunt it instantly felt faster, now that is no fair test… so a little bit of a Google search and I can confirm that yes in fact Gulp is the faster option.

The Key Difference

From my point of view the key difference between the two is the syntax in the task runner file.

Grunt uses JSON where as Gulp uses JavaScript.

I found Gulp a little easier to navigate and augment, it feels easier to customize and the ability to bind path names to variables was more familiar.

Reasons to use Grunt

Grunt has a longer History, more plugins and generally more support at the moment.

Before you choose Gulp check the plugin support for the tasks you need to run, it may be that some of the functionality you need currently only exists in a Grunt plugin and then using Gulp will not be possible.

Conclusion

Every article I have read seems to agree, Gulp is the task runner of choice among the cool kids. Gulp just feels right! At this point in time I have upgraded my task runner to Gulp, unless I have some major issues or problems with Gulp I don’t see any reason to use Grunt.

How to use node.js and npm behind a company firewall

This morning at work I tried to get YUIDoc up and running using the standard node.js npm install approach. At work we are behind a proxy which means you have to manually edit the node.js config.

The Error

If you get an error similar to this you’re probably being blocked by the company firewall.

npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "-g" "install" "yuidocjs"
npm ERR! cwd C:\Users\mfasani\Documents
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\mfasani\Documents\npm-debug.log
npm ERR! not ok code 0

The Fix

It’s easy to fix the above problem assuming it’s your company’s firewall causing the issue. Speak to the network team and find out the details of your work's proxy server. Then edit the node.js config as follows:

npm config set proxy http://proxy-server-address:8080
npm config set https-proxy http://proxy-server-address:8080

Now you should be able to continue using the npm to install your packages as normal.