Closed curldapps closed 4 years ago
@curldapps Hi thanks for informing this issue! I knew this unexpected behavior of Node.js 14 today.
Here is workaround I found a while ago:
import MsgReaderOrExports from '@kenjiuno/msgreader'
const MsgReader = MsgReaderOrExports.default || MsgReaderOrExports;
console.log(new MsgReader());
I'll continue to find a method to fix this problem!
Thanks so much, @kenjiuno!
Do you by chance have a little trick or workaround for Node 10 -> 12? :) I'd love to be able to import and use this using the require() syntax within my project natively. If not, I'll spin up a little containerized endpoint with Typescript and Node 14.
Cheers!
Ok, this will work on Node.js v12.17.0:
const MsgReaderOrExports = require('@kenjiuno/msgreader')
const MsgReader = MsgReaderOrExports.default || MsgReaderOrExports;
console.log(new MsgReader());
C:\A\t>node index2
MsgReader {
ds: DataStream {
_byteOffset: 0,
position: 0,
endianness: true,
_buffer: ArrayBuffer { [Uint8Contents]: <00>, byteLength: 1 },
_dataView: DataView { byteLength: 1, byteOffset: 0, buffer: [ArrayBuffer] },
_dynamicSize: true,
_byteLength: 1,
failurePosition: 0
},
fileData: undefined
}
I really appreciate it!
Solved using import methodology @kenjiuno suggested in Node 10
Hi - do you have any advice for using with node.js where import-as is not viable? I am locked into an older version of node.
UPDATE: Even using Node.js 14+ with import/export enabled I get "MsgReader" is not a constructor when I'm trying to make a new instance of the class in my app. Same goes for importing using require() in older versions of node :
const msgreader = require("@kenjiuno/msgreader")