Cannot find module 'mongoose' even though it exists - node.js

I am trying to run my node file but it gives me an error saying "Cannot find module 'mongoose'". I checked, I have mongoose in the node modules folder already. I have already tried deleting node module, packagelock.json and running npm install. I also tried downloading mongoose globally and linking them. None of them seem to work.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/mnt/c/Users/Ahsim Shakya/Desktop/LoginPage/database/models/userDetails.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/mnt/c/Users/Ahsim Shakya/Desktop/LoginPage/server/server.js:11:20)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)

had the same issue and this worked for me
rm -rf node_modules
npm install -g npm#latest
npm i core-util-is

Related

Cannot find module 'map-cache'

When I gulp serve my SPFx Webpart getting this error, also when creating a new webpart the result is same as below. I had searched a lot but I have not found any solution. Guys please help me to find out what is wrong.
D:\Mileage>gulp serve
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'map-cache'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\cdku7557807\AppData\Roaming\npm\node_modules
\gulp\node_modules\parse-filepath\index.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
install npm package
npm install map-cache --save

Error: Cannot find module 'symbol-observable' in Ionic 4

Tried running ng serve this error keep appearing
Error: Cannot find module 'symbol-observable'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\USER\AppData\Roaming\npm\node_modules\#angular\cli\lib\init.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
using npm
npm install --save symbol-observable
https://github.com/benlesh/symbol-observable
then import it where you using
import Symbol_observable from 'symbol-observable';

Error: Cannot find module 'gulp-serve'

Ran the following commands...
sudo npm install --save-dev gulp-serve -globally
into the directory where gulpfile.js lives. Whenever I run sudo gulp, I receive the following error...
module.js:472
throw err;
^
Error: Cannot find module 'gulp-serve'
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> (/var/www/html/bs4/gulpfile.js:2:14)
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)
Remove node_modules then install it without sudo:
npm i --save-dev gulp-serve

What is module.js 540 throw error?

Just installing node/npm first time, Linux Fedora: I've followed all the instructions and tried every fix I can find on google.
Whenever I try to run npm install or npm test I get this:
module.js:540
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
It was a bug and it has already been fixed in Node v5.4.1. Now it's working as usual.

Updating node.js possibly lead to npm error

I recently updated the node.js to the version 6.11.1. Got an error when accessing npm
When I tried to check the version of npm, the following error occurs
$ npm -v
module.js:471
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
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 C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
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)
After getting this error I updated the node.js to the latest version 8.1.4.
and the error is same with different line numbers.
$ npm -v
module.js:487
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
What is happening? Any fix to this issue?
At last, I got the solution.
I have copied all contents from
C:\Program Files\nodejs\node_modules\npm
and pasted it in
C:\Users\dino\AppData\Roaming\npm\node_modules\npm

Resources