1
resposta

[nodemon] app crashed

Estou tendo esse erro, procurei em outros lugares para tentar resolver mas não consegui.

PS C:\projetos> npm start

a4xb-teste-api@1.0.0 start C:\projetos nodemon index.js

[nodemon] 2.0.7 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,json [nodemon] starting node index.js consign v0.1.6 Initialized in C:\projetos

  • .\controllers\gameresult-controller.js C:\projetos\controllers\gameresult-controller.js:2 app.get('/gameresult', (req, res) => res.send('Resultado dos Jogos')) ^

ReferenceError: app is not defined at Object. (C:\projetos\controllers\gameresult-controller.js:2:1) at Module.compile (internal/modules/cjs/loader.js:1085:14) at Object.Module.extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module.load (internal/modules/cjs/loader.js:790:14) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:92:18) at Consign.into (C:\projetos\nodemodules\consign\lib\consign.js:232:15) at Object. (C:\projetos\index.js:9:6) at Module._compile (internal/modules/cjs/loader.js:1085:14) [nodemon] app crashed - waiting for file changes before starting...

    index.js

const express = require('express')

const consign = require('consign/lib/consign')

const app = express()

consign()
    .include('controllers')
    .into(app)

app.listen(3000, () => console.log('servidor rodando na porta 3000'))



    index.js 2

    const express = require('express')
const consign = require('consign')

const app = express()

consign()
    .include('controllers')
    .into(app)

app.listen(3000, () => console.log('servidor rodando na porta 3000'))
1 resposta

Olá, Carlos! Como vai?

Tente mudar a sua importação do Consign de:

const consign = require('consign/lib/consign')

Para:

const consign = require('consign')

Verifique se isso resolve, abraço!