npm Error “ Cannot find module 'npmlog' ” - node.js

I am running CentOS 6 and after logging in, I encounter the following error
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
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 /home/dspace/.nvm/v0.10.31/bin/npm:19:11
at Object.<anonymous> (/home/dspace/.nvm/v0.10.31/bin/npm:87:3)
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)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v0.10.31 --silent` to unset it.
I've discovered that it is a version bug and can be resolved either by upgrading the npm version or by deleting the node modules like so;
rm -rf node_modules
Then reinstalling them;
npm install
After removing the modules, npm install failed to run because of missing dependancies i.e. the modules. Now the command shows no response at all.
My node version is v0.10.48

This worked for me
Install nvm:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
Restart the terminal
Run
nvm install node
 

I had the same problem after proposed npm upgrade via npm -i -g npm. But Fedora npm/node installed via dnf has modules links to /usr/lib/node_modules/npm/node_modules.bundled/ from /usr/lib/node_modules/npm/node_modules/. I saw links were broken because usr/lib/node_modules/npm/node_modules.bundled/ disappeared. So reinstallation node,nodejs,npm via dnf/rpm solved the problem.

Related

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)
Most likely commander is missing from package.json. Install it and add it to package.json by doing:
npm install commander --save
Install commander globally.
sudo npm install commander -g
This will install commander module under/usr/lib/node_modules/.
Uninstalling sails and reinstalling with 'sudo' resolved it.
npm uninstall sails -g
sudo npm install sails -g
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..
In my case it was because of bad version of node. I've tried node 8.15.1 and it works.
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.

npm completely won't work: "Error: Cannot find module 'isarray'"

So every time I try us any npm command I get the same error:
module.js:472
throw err;
^
Error: Cannot find module 'isarray'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:32:15)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
Even when I try running npm install isarray I get the same exact error.
I've tried uninstalling the dependencies and then running npm install and I get the same error. I've tried completely reinstalling npm AND node and I still get the same error.
If I need this package to install this package I don't know what else to do.
In my case, this was cause of node and npm version.
Try to update your node and npm version.
First, Node update is
//Clean node Cache
sudo npm cache clean -f
//Install n Module
sudo npm install -g n
//Install stable Node version Using n Module
sudo n stable
IF this is not worked, then use 'nvm' (In my case, below is worked.)
nvm install 8.10.0
You can check your node version by 'node -v'
Second, npm update.
sudo npm install -g npm
You can also check your npm version by 'npm -v'
I hope this will be helpful!

bower install - Cannot find module 'q'

I'm using node v5.6.0 and bower 1.7.7 on a Mac.
I've done a npm install in my project folder which installs all the /node_modules including q.
I've also done a npm install -g q just to see if that helped.
But as soon as I run bower install (or just bower) anywhere I get
ambp:~ andreaslarsen$ bower
module.js:341
throw err;
^
Error: Cannot find module 'q'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/usr/local/bin/bower:6:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
Any suggestions?
I had this problem recently. I reinstalled bower globally. npm install and
"npm install -g bower" solved my problem. This downloaded the required folders in to node_modules directory globally and solved problem which I faced while installing packages with bower.
Turned out I just had to restart the terminal after doing the npm install and before doing the bower install
Works fine now
I also had this problem too, I tried a new terminal which didn't fix it, so I manually installed the missing module but it refused to find others, so upon further investigation it turned out to be a botched install of bower, which hadn't installed all its libs, so rerunning
npm install
fixed it for me.

NPM Cannot find module 'balanced-match'

Any command I'm try to run with npm I get:
module.js:340
throw err;
^
Error: Cannot find module 'balanced-match'
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/local/lib/node_modules/npm/node_modules/glob/node_modules/minimatch/ node_modules/brace-expansion/index.js:2:16)
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 Module.require (module.js:364:17)
Including when I try to npm install -g balanced-match
I know this is very old, and I hope that you found your answer, but for future questors:
I saw this issue recently when I tried to use npm after upgrading node to a newer version with n.
If you recently moved to a newer version of node, and you experience the error mentioned above, you may fix it by installing the latest version of npm. As this may not be possible, because npm is used to update itself, and npm is obviously not working:
Downgrade back to an earlier version of node where your copy of npm worked.
Update npm: sudo npm install npm#latest -g
Upgrade back to the version of node you were using before.
If that doesn't work, or you think it will be easier anyway, you may have to reinstall npm from binary.
If you haven't changed versions of node recently, you may need to reinstall node, or at least npm, from their websites.
I can suggest you the following link which suggest how to install
npm balanced-match
https://www.npmjs.com/package/balanced-match
or download from
github.com/juliangruber/balanced-match

Node not finding Less module

I am trying to install Node and Less on Ubuntu 12.1. Installing appears to work ok and I can see there is a Less folder created when I install Less using "sudo npm g install less" in:
/usr/local/lib/node_modules
However when I run "lessc -v" I get the below:
module.js:340
throw err;
^
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/bin/lessc:8:12)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Any ideas where I am going wrong?
You should create symlink to node modules directory into your home directory.
$ ln -s /usr/lib/node_modules/ ~/.node_libraries
(if you installed node from source it'll be /usr/local/lib/node_modules)
Modules installed in the "global scope" (which is what happens when you use npm -g install or install node modules from Ubuntu repositories, for example - sudo apt-get install node-less) are loaded by populating the NODE_PATH environment variable.
Packages installed from Ubuntu repositories handle this automatically, but if you install manually you have to set this yourself. In your case, you'd need to add the following command to your .bash_profile:
export NODE_PATH="$NODE_PATH:/usr/local/lib/node_modules"
sudo ln -s /etc/alternatives/node /usr/local/bin/node
It works at my Ubuntu 13.04

Resources