Open wildfire810 opened 5 years ago
can you provide a sample code to reproduce this issue?
Node v12.16.3 TypeScript v4.0.2
tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"allowJs": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"skipLibCheck": true,
"strictNullChecks": true,
"sourceMap": true,
"baseUrl": "src",
"sourceRoot": "src",
"outDir": "dist",
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
Source
import ReconnectingWebSocket from 'reconnecting-websocket';
console.log(ReconnectingWebSocket); // undefined
@pladaria I am having this problem too.
const ReconnectingWebSocket = require('reconnecting-websocket');
require is working btw.
I experience the same issue.
I fixed it by adding the following option to tsconfig.json in my project: "esModuleInterop": true
In my case "esModuleInterop": true
didn't help, but this did:
import ReconnectingWebSocket from 'reconnecting-websocket';
let rws: ReconnectingWebSocket.default;
rws = new (ReconnectingWebSocket as any)(connectionString, [], options);
reconnecting_websocket_1.default is not a constructor