Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems using your demo example #10

Closed
rtorsvik opened this issue Jan 28, 2019 · 3 comments · May be fixed by #26
Closed

Problems using your demo example #10

rtorsvik opened this issue Jan 28, 2019 · 3 comments · May be fixed by #26

Comments

@rtorsvik
Copy link

Dear tom-s,

I tried copying you "full example" into a .js file i called test-clap.js and tried running it but get the following error message. I also changed the first line from "import ClapDetector from 'clap-detector'" to "const ClapDetector = require('clap-detector')". I am new to node and hope this is a beginner mistake.

~/watson/test-clap $ sudo node test-clap.js
/home/watson/watson/test-clap/test-clap.js:4
const clap = new ClapDetector()
^

TypeError: ClapDetector is not a constructor
at Object. (/home/watson/watson/test-clap/test-clap.js:4:14)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)

the node_modules folder is in the same directory as ~/watson
I am running node version v9.11.2
strangely, it works when running your demo program as follows:
sudo node node_modules/clap-detector/lib/demo.js

@tom-s
Copy link
Owner

tom-s commented Jan 29, 2019

I suspect what you need is to do: const ClapDetector = require('clap-detector').default
if you console.log clapDetector, what does it look like ?

@rtorsvik
Copy link
Author

Adding .default worked for me. Thank you very much.

@axtux
Copy link

axtux commented May 1, 2020

Same issue, maybe you could include that in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants