Search code examples
node.jsexpressubuntu-13.10

Error with nodejs and express


I am trying to use express in an ubuntu 13.10 distribution. I am using node version 0.10.29 and npm 1.4.14 When I use express this is my output:

    module.js:340
       throw err;
      ^
    Error: Cannot find module 'mkdirp'
      at Function.Module._resolveFilename (module.js:338:15)
      at Function.Module._load (module.js:280:25)
      at Module.require (module.js:364:17)
      at require (module.js:380:17)
      at Object.<anonymous> (/usr/bin/express:10:14)
      at Module._compile (module.js:456:26)
      at Object.Module._extensions..js (module.js:474:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Function.Module.runMain (module.js:497:10)

Additionally, I have to use sudo npm as npm doesn't work (i'm not sure if that's part of the issue - but I suspect path issues, not really sure). I have googled but haven't been able to fix the issues.

Edit: I think I messed up my path. I am unable to reinstall npm. Here is output from $PATH

bash: /home/qtrain/npm/bin:/usr/bin/yo:/home/qtrain/.node/bin:/home/qtrain/Enthought/Canopy_64bit/User/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/qtrain/.rvm/bin:/home/qtrain/.rvm/bin:/home/qtrain/.rvm/bin:


Solution

  • The mkdirp error seems to originate from using the chris-lea repo for node.js as Michael answered.

    To fix: eliminate the PPA and node itself, then reinstall as below.

    1.) sudo apt-get install ppa-purge - if you don't already have it

    2.) sudo ppa-purge ppa:chris-lea/node.js

    3.) sudo apt-get remove nodejs

    4.) sudo apt-get remove npm

    5.) sudo apt-get autoremove

    6.) sudo apt-get install nodejs

    7.) sudo apt-get install npm

    8.) sudo apt-get install node-express