13

when I m running sails -v, sails lift or even installing npm I m getting this error Please help -

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)
Don
  • 503
  • 1
  • 4
  • 14

6 Answers6

12

Most likely commander is missing from package.json. Install it and add it to package.json by doing:

npm install commander --save
rtn
  • 127,556
  • 20
  • 111
  • 121
5

Install commander globally.

sudo npm install commander -g

  • This will install commander module under/usr/lib/node_modules/.
ahmnouira
  • 1,607
  • 13
  • 8
4

Uninstalling sails and reinstalling with 'sudo' resolved it.

npm uninstall sails -g

sudo npm install sails -g
Don
  • 503
  • 1
  • 4
  • 14
1

When i try setup new app with the help of express-generator. given error:Cannot find module 'commander'

Node version:12.16.1
switch node version :10.16.3

after switch node version is working fine..

Harendra Singh
  • 119
  • 1
  • 9
0

In my case it was because of bad version of node. I've tried node 8.15.1 and it works.

Iiskaandar
  • 394
  • 2
  • 7
0

On my end, after doing npm install, and attempt to run npm run watch I encountered this same issue of Error: Cannot find module 'commander'. I did below:

// delete node_modules (can do manually) or command below
// rm -rf node_modules
npm install

And I was able to do npm run watch again. This maybe because of corrupted packages.

Dharman
  • 30,962
  • 25
  • 85
  • 135
josevoid
  • 577
  • 7
  • 12