node.jsnpmsails.jsnpm-installnvm

Error: Cannot find module 'commander' at Function.Module._resolveFilename


When I'm running sails -v, sails lift or even installing npm, I am getting this error. How can I fix it?

Error: Cannot find module 'commander'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/sails/bin/_commander.js:6:15)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

Solution

  • Uninstalling sails and reinstalling with 'sudo' resolved it.

    npm uninstall sails -g
    
    sudo npm install sails -g