Friday, June 30, 2017

[SOLVED] - npm install crashes with error code 128

Error scenario:

You are trying to run npm install on an existing git repository, but your npm install stops somewhere at fetchMetadata and throws an error code 128, which doesn't tell you much.

First of all, there are multiple possible causes for error code 128, most of them have something to do with permissions, so make sure you have access permissions and you're using proper ssh key(if any).

However, if that doesn't solve the problem, you might try this:
Try to split the package.json file's dependency list into N subgroups and run npm install on those chunks.

This way, it will download some packages every time, and it won't download them anymore when you run npm install for the next chunk.

I'm not sure what's root cause of this bug, but it seems to be a potential bug in npm v.5.0.0+. This needs some more research, but for the moment, I hope that the trick of splitting the npm install load will do the trick for you!

This was tested with node v8.0.0.0 and v8.1.3  with npm v5.0.0 and v5.1.3.
OS: Ubuntu 16.04
(nvm was used as the node manager, and the package.json contained both free and private git repos hosted at bitbucket and github).

Possible reason for this error is the too high number of connections npm is trying to open. For some internet routers / connections, it might simply be too much. Currently, there's no official ability to limit max connections from npm, even there were some discussions on this in past. Lets hope this will be added into the newer versions.

Also, npm's error log is very bad at reporting the root cause of this error. In most cases, it simply says error code 128. However, every once in a while, it will print out something like Connection refused, or cannot connect to remote repository - host unknown, or something.

This error has a tendency to show up at large repos , filled with lots of git+ssh entries.

This issue might be somewhat related to this problem too:

sudo npm - command not found

Here is the solution if sudo npm is not working, while npm alone is:

up vote274down voteaccepted
Yes, it is a bit annoying but you can fix it with some links:
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
There might be more but that is all I have run across so far. Lack of node-waf will cause some npminstalls to fail with a rather cryptic error message.

Original post here:
ln (link creation function) is documented here:

Sunday, June 25, 2017

Session cookie not getting send or saved

If you are experiencing missing Session Cookie while using NodeJS (and probably any other server side framework), remember that:

Your client and your server should be on exactly the same domain. For example, if client is set to and connecting to server at http://localhost, cookie won't be saved - Web Browser is going to reject it (rejects Set-Cookie command to protect your safety)

Monday, June 19, 2017

Linux command to copy folder with hidden files

If cp command doesn't seem to work for you, and you see that hidden files are not getting copied to the destination directory, it's probably time to try rsync command!

Instead of:

cp src_dir target_dir -r

You can use:

rsync -av src_dir target_dir

Please note: Trailing slash is super important in rsync sytax. If you omit slash at the end of source directory, a new subdirectory will be created inside of target directory.

Sunday, June 18, 2017

David Allen, natural thinking process is: Why -> Vision -> Brainstorming -> Organization -> Next actions

In his superb book "Getting Things Done", David Allen introduced a phenomenal approach to creative project management. In one important section, he talks about natural order of thinking when looking to complete a non-trivial project. It is a powerful 5-step process:

1. Why

You MUST have a super strong WHY, if you hope to ever complete a complex project. Nothing below makes sense without a very powerful WHY.
If there are problems on lower levels of this hierarchy , always go back and redefine your WHY.

2- Vision of successful outcome

See yourself after the success. Vividly. It opens up your subconscious eyes to see things you've ignored all the time.

3. Brainstorming

This is beginning of How part. Write down, draw down all things that come to your mind for which you believe that could potentially help you realize the successful outcome you envisioned in step #2.

Mind mapping by Tony Buzan can help here.
Make no judgement and no analysis at this step. Every idea is a good idea.


Connect the dots, isolate the processes, streamline actions. Make some Gantt charts if needed.

5. Next actions

Make concrete action plan and execute them. After execution, move to Next action and redo.
Reward yourself for every action completed - it's one step forward to your successful outcome, it's a big thing!

Also, written plan of next actions help us focus and maintain it for a longer period. Most of us cannot focus more than a couple of minutes to the task at hand, without a significant external motivation. This is why written plan of next actions, and the vision of whole project is really helpful - it makes us feel more control over the project and increases our confidence in the whole project.

More tips - Vagrant on windows

These tips are about Vagrant on Windows, coupled with NFS using VirtualBox NFS plugin.

#1 If Vagrant ssh terminal is getting stuck
If your Vagrant ssh terminal is getting stuck all the time, check if you have multiple running vagrants: vagrant global-status and then halt / destroy them by id.

If NFS Enabled and plugin updated , but Vagrant still running slow:
Stop  it(vagrant halt)
Remove winnfsd.exe from memory (using Task manager)
Reload Vagrant machine (vagrant reload)
Try to access VM via IP

#2 If Vagrant VM is slow
Any wrong flag or option in Vagrantfile shared folder settings can degrade your VM's performance by 10x! For example, this is a valid synced folder entry for windows host using NFS:

config.vm.synced_folder ".", "/vagrant", type: "nfs"

Be careful when modifying this basic line, as any extra option can be the cause of slowliness of your VM.

Friday, June 16, 2017

Time saver - Quick fix for non working round() function in PHP

If there are some problems with rounding floats with round() function in PHP, such as too long decimal string, we can safely replace it with function number_format().

For example:

$rounded=round($x, 2);

can be replaced with:


Wednesday, June 14, 2017

1 week challenge - Let's not use ALT-TAB shortcut for one week

We all run  dozens of programs running simultaneously. We all use ALT-TAB to  quickly jump between those programs. ALT-TAB looks like a time saver. And it probably is. On the other side, we never consider a potential downside of using this, and other similar, keyboard  shortcuts:

ALT-TAB can severely reduce our concentration and therefore our productivity.

Pressing ALT-TAB will bring a new program to our screen instantly. Computer has no problems with fast context switching. But what about us - human beings? I'm not entirely convinced that we can do a quick context switch, without sacrificing our current thoughts.

Here is my challenge for you:

Can you try to avoid using ALT + TAB for 1 whole week. If you succeed at it, let us know how it felt? Has your productivity soared, jumped a little bit, or degraded?

I'm sure that there are some productivity awards for those who can endure this challenge. :)

Thursday, June 8, 2017

Webpack 2 - You may need an appropriate loader to handle this file type , error

When using webpack 2 with React, if you get a compile time error stating "You may need an appropriate loader to handle this file type.", and pointing to a JSX code block:

Make sure your babel-loader has appropriate include setting value.

An example:


                 options:{presets:['es2015', 'react']},



If include is set to a wrong path (not pointing to your source files), you're likely to see the error above. Tested with weback 2.6.

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...