Building the API | NodeJS, Express and Mongoose -  [3] Build a Task Manager w/ MEAN Stack

Building the API | NodeJS, Express and Mongoose - [3] Build a Task Manager w/ MEAN Stack

Devstackr

5 лет назад

40,494 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@fernyvelazquez3396
@fernyvelazquez3396 - 23.11.2023 07:17

im getting an error saying that nodemon is not recognized, is there anything i have to do? or did i maybe miss something?

Ответить
@user-jl9cq8kl5g
@user-jl9cq8kl5g - 12.06.2023 07:49

Hey, I am getting an error, when I command nodemon app.js
[nodemon] app crashed - waiting for file changes before starting...
What should I do?

Ответить
@drigo_ro
@drigo_ro - 03.05.2023 02:00

Great tutorial, amazing video!

im getting an error related to the version of my mongoose not suporting some features anymore when i try to launch nodemon app.js, someone can help me?

C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\node_modules\mongoose\lib\index.js:274
throw error;
^

SetOptionError: useCreateIndex: "useCreateIndex" is not a valid option to set
at Mongoose.set (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\node_modules\mongoose\lib\index.js:250:17)
at Object.<anonymous> (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\db\mongoose.js:13:10)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\app.js:4:20)
at Module._compile (node:internal/modules/cjs/loader:1254:14) {
errors: {
useCreateIndex: SetOptionInnerError [MongooseError]: "useCreateIndex" is not a valid option to set
at Mongoose.set (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\node_modules\mongoose\lib\index.js:252:33)
at Object.<anonymous> (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\db\mongoose.js:13:10)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (C:\Users\johnd\Documents\Faculdade\Codes\PI V\api\app.js:4:20)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
}
}

Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...

Ответить
@bonganimkonto
@bonganimkonto - 09.04.2023 18:18

Hello,

Just wanted to say thank you very much for this tutorial. I appreciate you sharing this knowledge on tackling express and mongodb. I have been a LAMP stack baby for a while so getting my head around the MEAN stack is proving to be a fun time.

Thanks again for this tutorial. 😁

Ответить
@rachanakafle5877
@rachanakafle5877 - 01.03.2023 09:55

I'm getting this error. Please help!!

List.find is not a function

LIST MODEL
const mongoose = require('mongoose');

const ListSchema = new mongoose.Schema({
title: {
type: String,
required: true,
minLength: 1,
trim: true
}
})

const List = mongoose.model('List', ListSchema);

module.exports = { List }

Ответить
@ozzy2361
@ozzy2361 - 30.12.2022 08:47

Wow, thank you so much. I picked up some great tips from this video.

Ответить
@sabrinaescarrega6990
@sabrinaescarrega6990 - 29.12.2022 08:00

Hey Um does this mean that users have access to all list and task ?

Ответить
@shaminibatwe
@shaminibatwe - 07.12.2022 08:12

nodemon command not found'

Ответить
@jonathanemanuel8737
@jonathanemanuel8737 - 02.12.2022 09:42

Hi! I'm loving your videos, I would like to know if, when the project is finished, I could upload it to my github. It's a sincere question. Thank you very much for the quality of the videos.

Ответить
@leandrocaldas4717
@leandrocaldas4717 - 21.11.2022 15:11

I confess that I found the sound of your keyboard keys very irritating. However, just mute it of course :). Regardless, excellent tutorial. Thank you very much.

Ответить
@shirahachmon
@shirahachmon - 28.08.2022 15:21

great thank you

Ответить
@bartvisser9760
@bartvisser9760 - 03.02.2022 21:54

Thank you so much! Great job! Perfect introduction to Angular etc.

Ответить
@EderSalcedoCastro
@EderSalcedoCastro - 11.10.2021 02:54

When I declare "const { mongoose } = require('./db/mongoose');" I get an error "Error: `useCreateIndex` is an invalid option."

Ответить
@EderSalcedoCastro
@EderSalcedoCastro - 11.10.2021 01:59

Amazing work man!

Ответить
@yk4628
@yk4628 - 16.07.2021 16:53

I dont have nodemon installed so first I have to install it ? then run cmd - nodemon app.js

Ответить
@komal6816
@komal6816 - 13.05.2021 07:16

const bodyParser = require('body-parser');
app.use(bodyParser.json()); // bodyParser is deprecated
Can anyone resolve ?

Ответить
@komal6816
@komal6816 - 13.05.2021 07:09

const {mongoose} = require('./db/mongoose');
mongoose is declared but its value is never read.
Can anyone resolve ?

Ответить
@vdeepak1654
@vdeepak1654 - 12.04.2021 15:19

Hi @Devstackr , Can you please show me how to create that TaskManager DB ..Because in this video when i abut run the code i am getting (MongooseServerSelectionError: connect ECONNREFUSED) . Then i realised that TaskManager DB we just passed in that Mongoose.js file ..But that DB doesn;'t exists...will you please help me

Ответить
@jaysonacosta6945
@jaysonacosta6945 - 26.02.2021 06:57

If any of you guys run into a problem where you're getting this:
(node:4802) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
Then run this command -> npm i [email protected]
Then inside of your mongoose.js file change -> mongoose.connect('mongodb://localhost:27017/TaskManager', {useNewUrlParser: true).then(() => {

to -> mongoose.connect('mongodb://localhost:27017/TaskManager', {useNewUrlParser: true, useUnifiedTopology: true}).then(() => {
Hope this helps someone!

Ответить
@nailaasgar2239
@nailaasgar2239 - 23.02.2021 14:09

Hi Sir, I am getting error while patch and delete, can you please help me

Ответить
@akshaybhaskare3711
@akshaybhaskare3711 - 11.02.2021 13:45

getting this error
UnhandledPromiseRejectionWarning: ValidationError: task validation failed: _listId: Path `_listId` is required.

// While creating a new task in a specific list
//here is my code

app.post('/lists/:listID/tasks', (req, res) => {

let newTask = new Task({
title: req.body.title,
_listId: req.params.listId
});

newTask.save().then((newTaskDoc) => {
res.send(newTaskDoc);
});

})

Ответить
@akshaybhaskare3711
@akshaybhaskare3711 - 27.01.2021 19:53

in my get all list route ,there is error 'Cannot read property 'find' of undefined'
each and every line of code of that route is correct, but i dont know where is the error i search it on google but no result

app.get('/lists', (req, res) => {
List.find().then((lists) =>{
res.send(lists);
}).catch((e) => {
res.send(e);
});
})

here is the code,please tell me where i wrong

Ответить
@SaiPrakash16
@SaiPrakash16 - 15.01.2021 21:59

Hi @Devstackr,
Any ideas on how to fix this would be greatly appreciated . Thanks.


(node:8620) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8620) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:8620) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:8620) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
C:\development\node-apis\my-mean-app\node_modules\mongoose\node_modules\mongodb\lib\operations\mongo_client_ops.js:474
throw err;
^

MongoError: database name must be a string
at Function.create (C:\development\node-apis\my-mean-app\node_modules\mongodb-core\lib\error.js:43:12)

Ответить
@meetpanchal1393
@meetpanchal1393 - 17.11.2020 10:04

Hey Sir, im getting node-sass error while running npm install in the frontend folder,any solution??

Ответить
@akshaybhanderi5168
@akshaybhanderi5168 - 26.10.2020 12:24

How to create database for that url we have specified

Ответить
@kamalkundla2906
@kamalkundla2906 - 20.10.2020 12:15

bro i got post errors when i tried to post the data in postman

Ответить
@Kolumbus69
@Kolumbus69 - 30.08.2020 18:00

function Model(doc, fields, skipId) {
if (fields instanceof Schema) {
throw new TypeError('2nd argument to `Model` must be a POJO or string, ' +
'*not* a schema. Make sure you\'re calling `mongoose.model()`, not ' +
'`mongoose.Model()`.');
}

Ответить
@aspektgaming7593
@aspektgaming7593 - 14.08.2020 00:34

Awesome videos thank you!!!

Ответить
@sivaramanl89
@sivaramanl89 - 17.06.2020 09:07

PS C:\New folder (2)\task-manager-mean-stack\api> node server
module.js:550
throw err;
^

Error: Cannot find module 'C:\New folder (2)\task-manager-mean-stack\api\server'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

Ответить
@anuragtripathi7744
@anuragtripathi7744 - 20.05.2020 01:30

sir please help,
I am getting this error:


D:\AngularProject\api>node app.js
D:\AngularProject\api\node_modules\mongoose\lib\index.js:174
if (VALID_OPTIONS.indexOf(key) === -1) throw new Error(`\`${key}\` is an invalid option.`);
^

Error: `userCreateIndex` is an invalid option.
at Mongoose.set (D:\AngularProject\api\node_modules\mongoose\lib\index.js:174:48)
at Object.<anonymous> (D:\AngularProject\api\db\mongoose.js:15:10)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (D:\AngularProject\api\app.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47

Ответить
@jawad9757
@jawad9757 - 27.04.2020 04:13

so first of all, I got an error telling me to call mongoose.model() instead of mongoose.Model(), so i did that and I didn't get any errors but i did get this severe looking warning:
(node:82281) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:82281) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:82281) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:82281) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
And I have tried everything to make that go away but i couldn't so i ignored it and then i tried to send a post request through postman with the title in the request body and then I get the error: List is not a constructor from this bit of code:
app.post('/lists', (req, res) => {
// Create new list and return that list as document (with ID)
// The list info fields will be passed in through the req.body
let title = req.body.title;


let newList = new List({
title
});
newList.save().then((listDoc) => {
res.send(listDoc);
})
});
I also tried a get request and i was returned the error: List.find is not a function.

Ответить
@antoniracing
@antoniracing - 16.04.2020 11:59

When im trying to delete both task or list postman sais <body>
<pre>ReferenceError: req is not defined<br> &nbsp; &nbsp;at C:\Users\anton\Desktop\task-manager\api\app.js:68:14


Also when im trying to patch both task or list it sais ok but it doesn't change the title why? i havent any error message.
the get and post functions works very well.

Ответить
@joaoantonio8516
@joaoantonio8516 - 24.03.2020 05:39

It keeps saying that app.use is not a function I don't get it

Ответить
@espe7378
@espe7378 - 24.02.2020 13:10

You know that you can use typescript with your nodejs backend? For some cases is better to have types.

Ответить
@frankzannimendez1851
@frankzannimendez1851 - 20.02.2020 02:20

Whenever I tried to update a task I got the 200 status code but when I verified with the app.get it still was in the list. So I changed app.patch('/lists/:listsId/tasks/:taskId', (req,res) =>{
Task.findOneAndUpdate ({
_id: req.params.taskId ,

_listId: req.params.listId
with
Task.findByIdAndUpdate
same thing with app.delete ( Task.findByIdAndRemove)


Just in case someone comes across this bug!

Ответить
@prasannav4987
@prasannav4987 - 22.01.2020 16:41

Hi bro
i am getting this error in 16.04
TypeError: Cannot read property 'find' of undefined
Thanks in advance bro

Ответить