To connect to live Mongodb - node.js

when i run this command:>npm run dev
restapi#1.0.0 dev
nodemon index.js
[nodemon] 2.0.20
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node index.js
Error while connecting
db = client.db('Aug_22');
^
TypeError: Cannot read properties of undefined (reading 'db')
trying to connect to live mongodb

It seems that it is not nodemon that makes problem, it is database connection probably.
Check the way you defined your client. Suppose there is some mistake, as error refers...

Related

'ts-node' is not recognized as an internal or external command, operable program or batch file error

npm start
start
nodemon index.ts
[nodemon] 2.0.15
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: ts,json
[nodemon] starting ts-node index.ts
'ts-node' is not recognized as an internal or external command, operable program or batch file
[nodemon] app crashed - waiting for file changes before starting...
Reinstall after npm install -gts-node, everything is the same error.

Unable to launch nodemon environment

I'm trying to start my server with nodemon, but it crashes with the following output.
The error ERROR: Unrecognized environment. Aborting. seems quite rare, from a Google search.
Ran the same code in Windows 10 and a WSL2 Ubuntu set up. Both had the same results. The server does start for my coworker for some reason, though.
user#LAPTOP:~/myproject$ npm run start:dev
> myproject#0.0.0 start:dev /home/user/myproject
> nodemon
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,html
[nodemon] starting `./node_modules/.bin/ts-node -r tsconfig-paths/register ./src`
[2021-03-23T04:11:42.704Z] ERROR: Unrecognized environment. Aborting.
[nodemon] app crashed - waiting for file changes before starting...
^C
user#LAPTOP:~/myproject$ npm -v
6.14.11
user#LAPTOP:~/myproject$ node -v
v15.12.0
This is a bug with my sequelize code
The issue came from trying to access the sequelize.js database before connecting to it.
Moving my Model.findAll() statement to after the app has launched has fixed the issue.

TypeError: Cannot read property '0' of undefined in web-server project of Nodejs-complete-course

[nodemon] restarting due to changes...
[nodemon] starting `node ./src/app.js`
[nodemon] restarting due to changes...
[nodemon] starting `node ./src/app.js`
Server is up on port 3000
/Users/xyz/Node-Course/web-app/src/utils/geocode.js:18
latitude: body.features[0].center[1],
^
TypeError: Cannot read property '0' of undefined
I am unable to debug this error occurs when i try to fetch a geo-codes[latitude, longitude] for a location using mapbox.com using callback and destructuring.
Resolved.
There was modification in API access token in the code while fetching the json data from API.If you are facing similar error than try verifying the access token in your code.

Trouble with nodemon: The server keeps restarting everytime I make change in the file, without executing the code

I am just getting started with node. I have installed the nodemon using the command npm install -g nodemon now whenever I start my server using nodemon server.js it starts fine but as I make some changes to the code it just keeps on restarting the server which doesn't execute the code in the file, so my progress is not saved.
Ansh#LAPTOP-7QQ43AM7 MINGW64 /f/files/atom/Web Development/my-express-server
$ nodemon server.js
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server has started on port 3000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
Instead of starting the server again after restarting, it just stays in the restarting process

MEAN starter kit showing error on installation

I wanted a mean starter kit so that I can build my app. Then I got this from github. I just made it setup then made npm install and then made npm start. But it showed me several errors like this
[nodemon] 1.12.1
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node server.js`
[0] ✓ App is running at http://localhost:3000 in development mode
[0] Press CTRL-C to stop
[0]
[1] Cannot read property 'config' of null
[1] TypeError: Cannot read property 'config' of null
[1] at Class.run (/Users/Sites/tryouts/mean/node_modules/#angular/cli/tasks/serve.js:51:63)
[1] at check_port_1.checkPort.then.port (/Users/Sites/tryouts/mean/node_modules/#angular/cli/commands/serve.js:123:26)
[1] at <anonymous>
[1] at process._tickCallback (internal/process/next_tick.js:188:7)
So can someone tell me how to make this working? Any help and suggestions will be really appreciable.

Resources