1

I had installed apache webserver on my local machine (Linux Mint 15) and everything was working fine until I tried to install npm/nodejs.

I'm getting this error whenever I try starting apache -

module.js:340
throw err;
      ^
Error: Cannot find module '/LANG=en_US.UTF-8'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

I have scoured the internet to find solution to this problem and make apache work again, but in vain.

My problem is thus - I don't need nodejs. I have removed and uninstalled npm and node using apt-get. I have manually removed all the node_modules and node directories from /usr/lib and ~. But the problem still remains.

I checked every .conf and .load file for apache and still cannot figure out where/how/why apache is loading module.js and node.js files from.

Can someone help with this?

EDIT:

Contents of my mods-enabled folder:

access_compat.load  authz_user.load  filter.load       php5.load
alias.conf          autoindex.conf   mime.conf         setenvif.conf
alias.load          autoindex.load   mime.load         setenvif.load
auth_basic.load     deflate.conf     mpm_prefork.conf  status.conf
authn_core.load     deflate.load     mpm_prefork.load  status.load
authn_file.load     dir.conf         negotiation.conf
authz_core.load     dir.load         negotiation.load
authz_host.load     env.load         php5.conf
Sterex
  • 111
  • 7
  • Check `ls /etc/apache2/mods-enabled/` if it's there do `a2dismod module` to disable and restart apache – LinuxDevOps Mar 22 '14 at 17:30
  • Updated the question with the contents of the `mods-enabled` folder. Don't think it's here. – Sterex Mar 22 '14 at 17:35
  • Check for any reference to module.js , node.js in apache configuration: `find /etc/apache2/ |xargs grep 'js'` – LinuxDevOps Mar 22 '14 at 17:38
  • @LinuxDevOps Nope. No references to any JS files in there. :\ – Sterex Mar 22 '14 at 17:46
  • Check if node is running already `ps -auxf|grep node` or `netstat -tlpn` – LinuxDevOps Mar 22 '14 at 22:43
  • Maybe `strace` can help You further: `sudo strace service apache restart` – czerasz Mar 23 '14 at 09:31
  • @LinuxDevOps Nope. Apache or node is not running. – Sterex Mar 23 '14 at 16:38
  • @czerasz Hey, thanks for the `strace` idea! I found that apache was erroring out when trying to execute nodejs related code in `/usr/bin/env` (See: http://imgur.com/XEtvPW6) So, is `/usr/bin/env` a nodejs related file? Why was this code (and much more) added to this file? Is it safe to remove it? – Sterex Mar 23 '14 at 16:50

1 Answers1

0

Ok, I finally got to the bottom of this!

Firstly, the problem (I suspect) was a corrupted /usr/bin/env file which was edited (perhaps by npm/nodejs installation) to load many (many, many) other files by additional shell script that looked node-related.

Secondly, mpm_prefork of apache2 installation was also corrupted - this is possibly my fault trying to find/fix the above error, I may have done something!

The solution was to reinstall everything -

sudo apt-get install --reinstall coreutils -- To fix the /usr/bin/env file.

sudo apt-get purge apache2 apache2-utils apache2.2-bin

sudo apt-get autoremove -- To uninstall and cleanup existing apache2 install

sudo apt-get install apache2 -- Fresh install of apache2

If someone is following this guide, don't forget to take backup of your virtual hosts configuration or custom php.ini configuration, if any.

Sterex
  • 111
  • 7