Nodejs 中将所有“import * from”转换为“const * = req() 的问题

问题描述 投票:0回答:1

有导入功能:

import socketIO, { Server as SocketIOServer } from "socket.io";

我想将其转换为

const socketIO, { Server as SocketIOServer } = require("socket.io")

但它不起作用,require 中的 type format 会怎样?

`

错误: 预计 TS1005','

javascript node.js socket.io requirejs require
1个回答
0
投票

通过以下代码解决:

const { Server: SocketIOServer, default: socketIO  } = require("socket.io")
© www.soinside.com 2019 - 2024. All rights reserved.