NPM broken mime-db missing - node.js

I had to reinstall Nodejs on my Macbook when I ran into an issue with npm.
No matter what I did I always got this output:
$ npm
Error: Cannot find module 'mime-db'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/form-data/node_modules/mime-types/index.js:2:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'mime-db'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I did not understand who this was happening. So I installed it one more time in hope that it would be fixed. No luck.
I did fix it after a wasting to much time. That is why I put it on here so that if anybody may walk into the same problem they solve it sooner then I did.

I used following command on node command prompt
npm install mime-db
It gave me warning: unmet dependency that it requires version 1.12 of mime-db, but it will download version 1.21 of mime-db
i ran the same command again i.e.
npm install mime-db
It solved my issue
Good Luck.
Another solution:
I was trying out something else, then I upgraded node package, downloading from node website and installing it, then i did not face this issue.
Thank you

After looking in the repo of mime-db and saw that I was missing this file in the module that was installed with the pkg. I added this file and now it works.
Good luck!

I deleted mime-db from the node_modules folder. Then I ran
npm i mime-db
That solved my problem.

Related

Can't install node modules globally. Module not found error

I am trying to install modules globally using npm but the command is always failing. I used npm already in the past and it worked without problems. Now, after sometime without using npm and after updating both node and npm, I am not being able to use npm install <module> -g commands.
I searched and often times the fix is to add a NODE_PATH to the system variables or adding npm/bin to the PATH. I tried it as well and it didn't fix my problem.
Fabio#DESKTOP-SQP25OA MINGW64 ~
$ echo $NODE_PATH
C:\Users\Fabio\AppData\Roaming\npm\node_modules
Fabio#DESKTOP-SQP25OA MINGW64 ~
$ npm install forever -g
Error: Cannot find module 'pinkie-promise'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Fabio\AppData\Roaming\npm\node_modules\npm\node_modules\request\node_modules\har-validator\lib\index.js:3:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Fabio\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "forever" "-g"
npm ERR! node v6.11.3
npm ERR! npm v4.1.2
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'pinkie-promise'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I also don't know why, but I have node_modules folders at these locations (maybe because of different versions installs):
C:\Users\Fabio\AppData\Roaming\npm\node_modules
C:\Users\Fabio\node_modules
C:\Program Files\nodejs\node_modules
Maybe I am adding the wrong path to my PATH and NODE_PATH variables?
For NODE_PATH I tried: C:\Users\Fabio\AppData\Roaming\npm\node_modules
And for PATH: C:\Users\Fabio\AppData\Roaming\npm\node_modules\npm\bin
Delete all node_modules on your system;
Remove all system and user variables related to node and npm;
Uninstall node;
Reinstall the latest version of node.
That is what worked at the end.
Looks like you need to install "pinkie-promise" first, looks like this module has dependency on that.
You need to install pinkie-promise first:
npm install pinkie-promise -g
After that, install forever:
npm install forever -g

npm install: Error : Cannot find module 'tough-cookie'

I have removed and reinstalled node.js many times
> node -v
4.5.0
> npm -v
3.3.6
Once I run the command npm install request I get the following error :
Error: Cannot find module 'tough-cookie'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\lib\cookies.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Generic User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "request"
npm ERR! node v4.5.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'tough-cookie'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
You probably will tell me to run
> npm update -g npm
I get the same error for this command too.
It looks like your version 3 npm install is broken, for some reason. It'd be interesting to know whether this path exists:
C:\Users\Generic User\AppData\Roaming\npm\node_modules\npm\node_modules\request\node_modules\tough-cookie
and whether it contains a valid package, etc.
With your npm v 3 install, broken, none of the npm install or update commands will work (as they'll need the request module). However, you might be able to roll back npm - as version 4.5.0 of Node.js installs npm version 2.15.9 and it will still be there:
> npm uninstall -g npm
That should leave you with:
> npm -v
2.15.9
Before re-installing npm v 3, clear the cache:
> npm cache clear
> npm install -g npm
However, before you re-install version npm v 3, it would be interesting to see if you are able to install request with npm v 2.
In my case it was a .lock file that caused this error, deleting the file fixed it. Same problem and solution was reported here: https://github.com/sass/node-sass/issues/2019
Is there a package.json file in the folder you are running node from?
If there is a package.json, then running :
npm install request
will not have the desired effect, in fact npm will just try and install whatever module is described in package.json
Have you tried npm install tough-cookie
it has worked for me
its browser issue ... please try to open it in chrome incognito windows or firefox private window and delete cookies

NPM: cannot find module './lib' after upgrading to Node.js 5.0 on OS X

Background
I just upgraded from Node.js v4.1.1 to v5.0.0 on my Mac. I used the node-v5.0.0.pkg installer from the node website because I don't have nvm or n installed, and I didn't install through Homebrew or MacPorts).
Problem
Now, every time I run npm I get the following error in my terminal:
Error: Cannot find module './lib'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/index.js:1:80)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './lib'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
I can't even re-install NPM through the traditional method of running npm install -g npm because the package manager itself doesn't work.
How do I get NPM working again on my Mac?
Solution:
rm -rf /usr/local/lib/node_modules/npm
Reinstall node js v5.0.0
Other notes:
Looks like other people are running in to the same problem (see issue #3606). It sounds like a fix is in the works, so this issue will probably be resolved in the next release. In the interim, the only solution is to completely purge npm from your system and reinstall.

node-sass install failing on Jenkins

I'm trying to set up Jenkins to run Gulp but it keeps failing while attempting to install node-sass (a dependency of the gulp-sass plugin).
The issue seems to be that node is not finding a script file during install. I verified that script does actually exist in the project repository. When I pull my repo locally on the server and install it, it installs without a problem. That makes me think it's a Jenkins related environment issue.
Here's the error output:
> node-sass#2.1.1 install /root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
module.js:338
throw err;
^
Error: Cannot find module '/root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "node" "/home/ec2-user/.linuxbrew/bin/npm" "install" "--production"
npm ERR! node v0.12.2
npm ERR! npm v2.7.6
npm ERR! code ELIFECYCLE
npm ERR! node-sass#2.1.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#2.1.1 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/.jenkins/jobs/odyssey-frontend/workspace/npm-debug.log
module.js:338
throw err;
^
Error: Cannot find module 'gulp-sass'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/root/.jenkins/jobs/odyssey-frontend/workspace/gulpfile.js:11:12)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The Linux distribution is Amazon Linux AMI, Fedora-like. Trying to install node-sass ^2.0.1 via gulp-sass ^1.3.3.
I just tried the updated gulp-sass 2.0.0 with node-sass 3.0.0 and still have the same issue.
I removed all node-sass dependencies and it builds successfully now. So its really just that package; all other node packages install successfully.
I posted this on the Github project where it was answered: https://github.com/sass/node-sass/issues/941#issuecomment-100414516
Jenkins seems to run everything as sudo when building. NPM, as a security feature, won't run install scripts as sudo, hence the error. Adding a --unsafe-perm flag to the install script gets by this issue.

npm install i18next-conv: Error: Cannot find module 'readable-stream'

I'm trying to install i18next-conv but, when I run sudo npm install i18next-conv -g, I get this error:
Error: Cannot find module 'readable-stream'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/sha/index.js:3:48)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
If you need help, you may report this log at:
<http://github.com/isaacs/npm/issues>
or email it to:
<npm-#googlegroups.com>
System Darwin 11.4.2
command "node" "/usr/local/bin/npm" "install" "i18next-conv" "-g"
cwd /Users/personalcomputer/Desktop
node -v v0.6.18
npm -v 1.3.5
Additional logging details can be found in:
/Users/personalcomputer/Desktop/npm-debug.log
not ok code undefined
not ok code 1
Can anyone tell me what can I do to install it?
Thanks!
I think this should be solved if you update node.js and possibly npm as well.
Note you can update npm with npm itself via the command:
sudo npm install -g npm
What I had to do was update node version from node web page

Resources