How to fix this error: app crashed - waiting for file changes before starting?

As a beginner, I followed a webdevsimplified course. I can not fix this error -> [nodemon] app crashed - waiting for file changes before starting... I attach also a photo if it helps.
No description
40 Replies
Jochem
Jochem4mo ago
src as a variable is undefined usually that means you tried to use querySelector and it failed to find the element you're looking for though I suppose in this case with node, it's something different. Impossible to tell without more info though
INDavid04
INDavid04OP4mo ago
yeah it makes sense, but node_modules is installed with npm i express ejs express-ejs-layouts and I did't modified those files at all
Jochem
Jochem4mo ago
you might be missing a .env file in your project root then? Otherwise, no idea
INDavid04
INDavid04OP4mo ago
.env is in the project root with this line DATABASE_URL=mongodb://localhost/mybrary should i change what is after localhost/? also in the video tutorial he used .load(), specifying after to use .parse() instead
INDavid04
INDavid04OP4mo ago
here is where he used the function
No description
INDavid04
INDavid04OP4mo ago
I saw in comments to use .config() instead, but got another error
glutonium
glutonium4mo ago
where is src coming from? like where is it defined
INDavid04
INDavid04OP4mo ago
1 sec
INDavid04
INDavid04OP4mo ago
No description
INDavid04
INDavid04OP4mo ago
however, after repacing parse() with config(), i got this Error: Cannot find module 'mangoose'
glutonium
glutonium4mo ago
dud u install mongoose? run npm i mongoose if not what does the variabe src represent?
INDavid04
INDavid04OP4mo ago
No description
INDavid04
INDavid04OP4mo ago
I don't know, but I do not use the parse() function anymore
glutonium
glutonium4mo ago
can u show the code where u r requiring mongoose u dont know? wdym u dont know the function u r trying to run even takes as arguments
INDavid04
INDavid04OP4mo ago
I said I am new to this stuff
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}

const express = require('express')
const app = express()
const expressLayouts = require('express-ejs-layouts')

const indexRouter = require('./routes/index')

app.set('view engine', 'ejs')
app.set('views', __dirname + '/views')
app.set('layout', 'layouts/layout')
app.use(expressLayouts)
app.use(express.static('public'))

/// Right here
const mangoose = require('mangoose')
mangoose.connect(process.env.DATABASE_URL, {useNewUrlParser: true })
const db = mangoose.connection
db.on('error', error => console.error(error))
db.once('open', () => console.log('Connected to Mongoose'))

app.use('/', indexRouter)

app.listen(process.env.PORT || 3000)
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}

const express = require('express')
const app = express()
const expressLayouts = require('express-ejs-layouts')

const indexRouter = require('./routes/index')

app.set('view engine', 'ejs')
app.set('views', __dirname + '/views')
app.set('layout', 'layouts/layout')
app.use(expressLayouts)
app.use(express.static('public'))

/// Right here
const mangoose = require('mangoose')
mangoose.connect(process.env.DATABASE_URL, {useNewUrlParser: true })
const db = mangoose.connection
db.on('error', error => console.error(error))
db.once('open', () => console.log('Connected to Mongoose'))

app.use('/', indexRouter)

app.listen(process.env.PORT || 3000)
ἔρως
ἔρως4mo ago
cannot find module mangoose you installed mongoose
INDavid04
INDavid04OP4mo ago
no way
ἔρως
ἔρως4mo ago
way
INDavid04
INDavid04OP4mo ago
glutonium
glutonium4mo ago
i get that but u wont be able to debug if u dont know what your code does u should understand what the function expects
ἔρως
ἔρως4mo ago
this is correct
glutonium
glutonium4mo ago
if u blindly follow someones footstep u will lose yourself pretty easily
ἔρως
ἔρως4mo ago
lose not loose
INDavid04
INDavid04OP4mo ago
so true
glutonium
glutonium4mo ago
;-;
ἔρως
ἔρως4mo ago
loose is the oposite of tight, lose is the oposite of find
glutonium
glutonium4mo ago
i mix them up all the time 😭
INDavid04
INDavid04OP4mo ago
i tried to understand but is very different from what i did in highscool with c++
ἔρως
ἔρως4mo ago
it is, but it isnt as hard as you think its always overwhelming at first
INDavid04
INDavid04OP4mo ago
sure
ἔρως
ἔρως4mo ago
it gets a lot easier
INDavid04
INDavid04OP4mo ago
hmm should i show you that?
INDavid04
INDavid04OP4mo ago
No description
ἔρως
ἔρως4mo ago
its mongoose not mangoose
INDavid04
INDavid04OP4mo ago
lol
ἔρως
ἔρως4mo ago
mongoose for mongodb, right?
INDavid04
INDavid04OP4mo ago
oh yeah in my native language 'o' is heard like 'a'
ἔρως
ἔρως4mo ago
mangoose sounds like a shitty superhero with awful super powers languages are fun
INDavid04
INDavid04OP4mo ago
thanks a lot guys, now it is works
ἔρως
ἔρως4mo ago
you're welcome
Want results from more Discord servers?
Add your server