Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

405
Visualizações
SyntaxError: Cannot use import statement outside a module when setting up socket.io in adonisjs

am following socketio with adonisjs to be able to implement web sockets but I get this error

[ info ]  building project...
[ info ]  starting http server...

SyntaxError: Cannot use import statement outside a module

at /home/../providers/AppProvider.ts(anonymous):18
13    }
14  
15    public async ready () {
16      // App is ready
17      if (this.app.environment === 'web') {
18        await import('../start/socket')
19  
20      }
21    }
22  
23    public async shutdown () {

[ encore ] Running webpack-dev-server ...
[ warn ]  Underlying HTTP server died with "0 code"

when I try out this solution of adding "type": "module", to package.json I get other errors

how can I fix this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Turns out I was using a start/socket.js instead of start/socket.ts.

about 4 years ago · Juan Pablo Isaza Relatório

0

{
  "name": "socket",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "nodemon": "^2.0.15",
    "socket.io": "^4.4.0"
  }
}

Check your package.json file, "type": "module" is missing , Make sure to add this as shown in this one !!!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda