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
Jochem3mo 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
INDavid04OP3mo 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
Jochem3mo ago
you might be missing a .env file in your project root then? Otherwise, no idea
INDavid04
INDavid04OP3mo 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
INDavid04OP3mo ago
here is where he used the function
No description
INDavid04
INDavid04OP3mo ago
I saw in comments to use .config() instead, but got another error
glutonium
glutonium3mo ago
where is src coming from? like where is it defined
INDavid04
INDavid04OP3mo ago
1 sec
INDavid04
INDavid04OP3mo ago
No description
INDavid04
INDavid04OP3mo ago
however, after repacing parse() with config(), i got this Error: Cannot find module 'mangoose'
glutonium
glutonium3mo ago
dud u install mongoose? run npm i mongoose if not what does the variabe src represent?
INDavid04
INDavid04OP3mo ago
No description
INDavid04
INDavid04OP3mo ago
I don't know, but I do not use the parse() function anymore
glutonium
glutonium3mo 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
INDavid04OP3mo 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)
ἔρως
ἔρως3mo ago
cannot find module mangoose you installed mongoose
INDavid04
INDavid04OP3mo ago
no way
ἔρως
ἔρως3mo ago
way
INDavid04
INDavid04OP3mo ago
glutonium
glutonium3mo 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
ἔρως
ἔρως3mo ago
this is correct
glutonium
glutonium3mo ago
if u blindly follow someones footstep u will lose yourself pretty easily
ἔρως
ἔρως3mo ago
lose not loose
INDavid04
INDavid04OP3mo ago
so true
glutonium
glutonium3mo ago
;-;
ἔρως
ἔρως3mo ago
loose is the oposite of tight, lose is the oposite of find
glutonium
glutonium3mo ago
i mix them up all the time 😭
INDavid04
INDavid04OP3mo ago
i tried to understand but is very different from what i did in highscool with c++
ἔρως
ἔρως3mo ago
it is, but it isnt as hard as you think its always overwhelming at first
INDavid04
INDavid04OP3mo ago
sure
ἔρως
ἔρως3mo ago
it gets a lot easier
INDavid04
INDavid04OP3mo ago
hmm should i show you that?
INDavid04
INDavid04OP3mo ago
No description
ἔρως
ἔρως3mo ago
its mongoose not mangoose
INDavid04
INDavid04OP3mo ago
lol
ἔρως
ἔρως3mo ago
mongoose for mongodb, right?
INDavid04
INDavid04OP3mo ago
oh yeah in my native language 'o' is heard like 'a'
ἔρως
ἔρως3mo ago
mangoose sounds like a shitty superhero with awful super powers languages are fun
INDavid04
INDavid04OP3mo ago
thanks a lot guys, now it is works
ἔρως
ἔρως3mo ago
you're welcome
Want results from more Discord servers?
Add your server