Комментарии:
im getting an error saying that nodemon is not recognized, is there anything i have to do? or did i maybe miss something?
Ответить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?
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...
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. 😁
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 }
Wow, thank you so much. I picked up some great tips from this video.
ОтветитьHey Um does this mean that users have access to all list and task ?
Ответитьnodemon command not found'
Ответить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.
Ответить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.
Ответитьgreat thank you
ОтветитьThank you so much! Great job! Perfect introduction to Angular etc.
ОтветитьWhen I declare "const { mongoose } = require('./db/mongoose');" I get an error "Error: `useCreateIndex` is an invalid option."
ОтветитьAmazing work man!
ОтветитьI dont have nodemon installed so first I have to install it ? then run cmd - nodemon app.js
Ответитьconst bodyParser = require('body-parser');
app.use(bodyParser.json()); // bodyParser is deprecated
Can anyone resolve ?
const {mongoose} = require('./db/mongoose');
mongoose is declared but its value is never read.
Can anyone resolve ?
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
Ответить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!
Hi Sir, I am getting error while patch and delete, can you please help me
Ответить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);
});
})
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
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)
Hey Sir, im getting node-sass error while running npm install in the frontend folder,any solution??
ОтветитьHow to create database for that url we have specified
Ответитьbro i got post errors when i tried to post the data in postman
Ответить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()`.');
}
Awesome videos thank you!!!
Ответить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
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
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.
When im trying to delete both task or list postman sais <body>
<pre>ReferenceError: req is not defined<br> 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.
It keeps saying that app.use is not a function I don't get it
ОтветитьYou know that you can use typescript with your nodejs backend? For some cases is better to have types.
Ответить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!
Hi bro
i am getting this error in 16.04
TypeError: Cannot read property 'find' of undefined
Thanks in advance bro