Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'commander'

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)
like image 276
Don Avatar asked Mar 20 '18 20:03

Don


People also ask

What does Cannot find module mean?

Why the "Error: cannot find module" Occurs. This error occurs because of the following reasons: you're trying to import an item from a module you don't have installed in your project directory. you're importing some things from an outdated package. you're pointing to a file that does not exist.

Can not find module NPM?

To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.

Can not find module node JS?

If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.


2 Answers

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

npm install commander --save
like image 116
ralphtheninja Avatar answered Oct 03 '22 05:10

ralphtheninja


Install commander globally.

sudo npm install commander -g

  • This will install commander module under/usr/lib/node_modules/.
like image 42
ahmnouira Avatar answered Oct 03 '22 04:10

ahmnouira