Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

SyntaxError: Unexpected token . - não encontro o erro

O erro

C:\Users\YuriPNP\Desktop\pwd\payfast\config\custon-express.js:10
  .include('controles');
  ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:743:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (C:\Users\YuriPNP\Desktop\pwd\payfast\index.js:1:11)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
[nodemon] app crashed - waiting for file changes before starting...

arquivo index.js

var app = require('./config/custon-express');

app.listen(3000, function() {
  console.log('Servidor rodando na porta 3000')
})

arquivo custon-express

var express = require('express'); // carregando a lib com seus arquivos
var consign = require('consign');


module.exports = function() {
  var app = express(); // referenciando o objeto express - app é a referencia do objeto express


   consign();
  .include('controles');
  .into(app);

  return app;

}

arquivo do pagamento

module.exports = function(app) {
  app.get('/pagamentos', function(req, resp){
    console.log('recebida requisição de teste na porta 3000');
    resp.send('ok');
  })

}
4 respostas

O problema está no arquivo custom-express.js. Tente alterar a configuração do consign para ficar desta forma:

   consign()
  .include('controles')
  .into(app);

Olá Daniel, tudo bem ? ainda dá problema, mas é outro. agora

C:\Users\YuriPNP\Desktop\pwd\payfast>nodemon index.js
[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
C:\Users\YuriPNP\Desktop\pwd\payfast\index.js:3
app.listen(3000, function() {
    ^

TypeError: app.listen is not a function
    at Object.<anonymous> (C:\Users\YuriPNP\Desktop\pwd\payfast\index.js:3:5)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
    at internal/main/run_main_module.js:21:11
[nodemon] app crashed - waiting for file changes before starting...
solução!

No seu arquivo index.js, faça a seguinte alteração:

var app = require('./config/custon-express')();

app.listen(3000, function() {
  console.log('Servidor rodando na porta 3000')
})

Caramba Daniel, valeu. Tu é o Cara. era isso mesmo

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software