Error installing mongodb - node.js

I'm a beginner in nodejs and mongodb. I have been working on a project for a while using MEAN stack. It also uses mongojs and mongoose extentions which were working fine until now.
I'm following this tutorial.
A server.js file helps me connect my project with the database. I'm getting the following mongodb error on running the server.js file which was not present until now.
C:\Program Files\nodejs\easy-node-authentication-local1>node server1
module.js:327
throw err;
^
Error: Cannot find module 'mongodb'
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:\ProgramFiles\nodejs\node_modules\mongojs\lib\collection.js:1:77)
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)
I'm unable to install mongodb using 'npm install mongodb' because of the following error.
C:\Program Files\nodejs>npm install mongodb
npm ERR! fetch failed https://registry.npmjs.org/mongodb/-/mongodb-2.2.12.tgz
npm WARN retry will retry, error on last attempt: Error: unable to verify the first certificate
Can anyone help me understand this problem.

I do not understand the need of server.js for installing mongoDB.
But I recently tried installing, and it worked for me
make sure you have all dependencies installed.
I suggest you to npm install tar -g and then npm install mongodb -g

have you any proxy in network?
If yes you must configure with npm. Check this link

Related

I got following error while developing in MEAN stack : Cannot find module 'mongojs'

I ran command: node server in bash on Ubuntu and below is the error I got:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mongojs'
Require stack:
- /home/nishil/Documents/contactListApp/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/nishil/Documents/contactListApp/server.js:5:15)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/nishil/Documents/contactListApp/server.js' ]
}
How can I resolve this error?
Please check in your package.json file if mongojs is installed or not.
If it is then remove package-lock.json and remove node_modules folder and install node modules again by npm i.
If mongojs is not installed then you can do that using npm i mongojs command
But i would suggest please change your package from mongojs to mongodb https://www.npmjs.com/package/mongodb
As mongojs is seems outdated its not updated since last 3 years it has 27 open issues since very long.
Let me know if this solutions works for you..
If you want to use mongojs or any other module, please make sure it's there in package.json and you have run yarn install or npm install in that directory containing the package.json. If the problem still persists, try deleting the node_modules folder in this directory and try running yarn install or npm install again.

NPM Fails install of bcrypt on ElasticBeanstalk

I have everything running fine locally here on OSX and I am trying to deploy this to aws elasticbeanstalk. During the deployment process I was getting an error such as the following
bcrypt#1.0.3 install /tmp/deployment/application/node_modules/bcrypt
node-pre-gyp install --fallback-to-build
module.js:471
throw err;
^
Error: Cannot find module '../'
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>
(/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
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)
I have read that this appears to be an issue with npm install and that I should add bcrypt directly to my package.json file for a dependency and I have done just that.
I was able to replicate the issue locally by deleting my node_modules folder and trying to run npm install without having bcrypt as a dependency. I then deleted the node_modules folder again and added bcrypt as a direct dependency and npm install worked just fine.
However I cannot seem to get this to resolve itself on elasticbeanstalk. When I ssh into the instance there is no node or npm in the path, I am not sure where they are installed to on ElasticBeanstalk. I did find that the deployment is under /tmp/deployment/application and I tried to remove the node_modules directory and deploying again however that did not solve the issue either.
You might wanna make sure the beanstalk instance has Python 2.x installed as BCrypt relies on this in order for it to work.
Also, beanstalk apps are installed in the following path: /var/app/current

NodeJS Error: Cannot find module './lib/oauth'

After cloning my test site from github and succeeding to remove the default version of node on my raspberry pi 3 and installing V8.5.0, I ran npm install and npm install nodemon -g. Now however I am unable to run my script due to an error:
module.js:529
throw err;
^
Error: Cannot find module './lib/oauth'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object. (/home/pi/Projects/EncodedB0t/node_modules/request/request.js:28:13)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
I've tried adding npm install oauth --save to no avail and haven't been able to find an answer online.
Any help would be appreciated!
Edit: added my github repo, https://github.com/TheWalkingM3m3/EncodedB0t
Try run npm install request --save. Then rename oauth.js.example in your root directory on oauth.js. It's works in my case.

error cannot find module 'umask'

I just installed nodejs x64 on my Windows 10 computer. I keep all default config,
I open cmd and type:
npm -v
Then i got following error:
module.js:457
throw err;
^
Error: Cannot find module 'umask'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\W10-PRO\AppData\Roaming\npm\node_module\npm\lib\utils\umask.js:1:75)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
Every command start with "npm" create this error and npm cannot uninstall, update itself)
Please help me fix this error?
update your npm
$ npm install npm -g
I would try to update/install NPM
$ npm update -g npm
I know the answer!
Uninstall nodejs.
Delete all references to npm and nodejs (Program Files, Program Files(x86).
Then also delete those in AppData/Roaming (npm and npm-cache to be sure).
Reinstall nodejs.
It works!

How to install: caress server node server.js . Error: 'Cannot find module '....buffertools.node'

I am installing the the library found from MIT students using TUIO. According to their instructions I was supposed to start the server but I got an error.
Does anyone know how to fix this error?
C:\Users\PC\Desktop\server1.1>node examples/server.js
info - socket.io started
module.js:442
throw err;
^
Error: Cannot find module './build/Debug/buffertools.node'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\PC\Desktop\server1.1\node_modules\buffertool
s\buffertools.js:26:20)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
I tried following there steps and got my server stared.
I think you are missing npm i after cloning repo.
please do npm i and try starting server
You need to install the dependency packages before you can run your project.
npm install looks for the packages listed in the package.json file and installs them with their dependencies recursively.
If you are getting specific error in installation of particular package, it could be internet issue/os issue and most probably node and npm version issue. Make sure you are using a stable version of node, its version no should be even.

Resources