node-bin-packing icon indicating copy to clipboard operation
node-bin-packing copied to clipboard

"TypeError: Packer is not a constructor" ?

Open robert-barcelona opened this issue 6 years ago • 0 comments

I'm using binpacking in a create-react-app application with node 10 and getting the following error:

Uncaught TypeError: Packer is not a constructor


import binpack from 'binpacking'

const Packer = binpack.Packer

console.log(binpack)

const packer = new Packer(30,20)

The offending line is const Packer = binpack.Packer

The main file for the NPM package is (in its entirety)

exports.GrowingPacker = require('./packer.growing.js').GrowingPacker;
exports.Packer = require('./packer.js').Packer;

When I console log binpack I see that both GrowingPacker and Packer are undefined.

I'm at a loss here -- I'm sure it's something to do with requires or imports, but I'm lost. I tried using 'require' in my file in place of 'import', but it changed nothing.

robert-barcelona avatar Jun 18 '19 23:06 robert-barcelona