【发布时间】:2021-12-25 22:18:55
【问题描述】:
我正在关注socketio with adonisjs 以便能够实现 Web 套接字,但我明白了 这个错误
[ 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"
当我尝试将 "type": "module", 添加到 package.json 的 solution 时,我得到了其他错误
我该如何解决这个问题?
【问题讨论】:
-
你能分享更多代码吗?
-
你想看看 start/socket.js 里有什么
-
在哪里导入socket io模块?
-
在
app/Services/Ws.ts就像this says。我尝试添加代码,但对于帖子来说太多了
标签: javascript import async-await socket.io adonis.js