Random thoughts & observations

From the mundane to the profound and everything in between here’s what’s rocking our world

Resolving node module did not self register errors

Posted: March 15, 2015
Written by: Saints At Play
Category: Node JS

If you've recently updated your existing Node installation to v0.12 and have success with starting your server then congratulations. However it might be the case that you are experiencing the following error warning when trying to launch your Express Framework application from the command line:

[Error: Module did not self-register.]

Not the best result right? Here's how we resolved the issue and got our Express apps working again.

Version Management is key

As wonderful a development tool as Node can be, and often is, it can also be a major pain in the arse to get working when updates break pre-existing functionality. One way of circumventing problems with updates (other than not updating your existing installation/packages to begin with - which might not be advisable in the long run) is to manage separate installations of Node using the Node Version Manager or NVM for short.

NVM allows you to install multiple versions of Node to your system and select which version you want to run through simple commands issued in the Terminal.

If NVM is not already installed on your system (check through running the command: nvm --version in your Terminal - if installed you'll see a version number being displayed, if not the Terminal shell simply won't recognise the command) then run the following:

curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

If you see the following error being returned at the end of the installation process:

=> Appending source string to /Users/yourUserName/.bashrc
bash: line 216: /Users/yourUserName/.bashrc: Permission denied

Don't worry, the software has been installed it just wasn't able to be added to the system path to allow for NVM to automatically be able to be called from the shell. We can rectify that with the following addition to your .bash_profile (or whatever shell configuration file you use):

[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh"

Save your edited shell configuration file and now, still within your Terminal, install a previous version of node (the actual version really doesn't matter as you can install multiple different versions using NVM) with the following command:

nvm install 0.10.32

If you open a new Terminal window then you'll need to instruct your shell to use the particular version of Node that you just installed:

nvm use 0.10.32

Now in the same Terminal window navigate to wherever your Express Framework project is located and execute the following command to launch the server:

node bin/www

The server should now start without displaying any error messages, unlike earlier in the article when we tried to do so with the latest node update.

In your browser of choice type out the path to your project, for example:

// The following presumes your node port is 3000 - if not, then change 
// to the correct port number instead
http://localhost:3000

And, all things being well you should see your Express Framework application being proudly displayed in the browser window.

« Return to Posts

Comments

Gravatar
Lommekniv Victorinox

June 5, 2015

Gгeat pօst. I am going through many of these issues as well..

Posting comments after three months has been disabled.