Code Monkey home page Code Monkey logo

Comments (8)

DrCWO avatar DrCWO commented on June 2, 2024

Next I tried to dynamically import so I did:
var flacBindings = require('flac-bindings');
instead of
var flacBindings = require('flac-bindings');

But then I get an error in the next line if I like to create an instance of StreamEncoder:

/home/pi/rooExtend/modPlay.js:928
                var encoder = new StreamEncoder({
                              ^

TypeError: StreamEncoder is not a constructor

from node-flac-bindings.

DrCWO avatar DrCWO commented on June 2, 2024

OK, for all with the same issue I will publish the solution 👍

This was the code before:

var flacBindings = require('flac-bindings');
StreamEncoder = flacBindings.StreamEncoder;
// ... your code continues here...

This is the code that you have to use now. It dynamically loads the module and this takes some time.
Therefore you have to wait and continue asynchronously...

		import('flac-bindings')
			.then(flacBindings => {
				StreamEncoder = flacBindings.StreamEncoder;
				// ... after loading the flac-bindings your code continues here...
			})
			.catch(err => {
				console.log('Cannot load flac-bindings ' + err);
			})

Hope this is useful for someone else but me.

@melchor629
will be great if you might add this to your README file

Best DrCWO

from node-flac-bindings.

melchor629 avatar melchor629 commented on June 2, 2024

Hi DrCWO! Thanks for opening the issue.

This is a known "pain point" of the 3.x series. In release notes I pointed it out that this was happening and added this link https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c which explains a bit what happens and what you can do to fix it. You can always keep using 2.x series meanwhile or use the dynamic import() syntax.

In addition, because I imagined that this would be a recurrent issue, the README also contains this line to warn the devs. I see I should make it even clearer.

Sorry for this confusion. I wanted to move forward with the technology and I know that this can be a bit frustrating. I hope you could find the above link useful.

from node-flac-bindings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.