Installing a library with JS
Hello,
I'm trying to build a demo bar code scanner. I found this library:
https://serratus.github.io/quaggaJS/#node-example
I've installed Node + Quagga (library)
My dependencies are the following:
However, when running test script (provided in docs), I get this error
ReferenceError: require is not defined
at scan.js:71:14
which makes me believe I've installed wrong. Any ideas how to fix this?
Sample script ran:
QuaggaJS, an advanced barcode-reader written in JavaScript
QuaggaJS is an advanced barcode-reader written in JavaScript
18 Replies
did you run npm install in your project folder?
Yes I did. My script tag also has module attribute
oh, i tested it with this in the first line and it worked, maybe try it
var Quagga = require('quagga').default;
Same issue
Which commands did you run?
@Heitor is this because I'm running node in browser without express?
not sure, I installed the library with npm, created a file index.js with the example and ran "node index.js" in the terminal
Hmm
I'm lost right now keep getting this error
ReferenceError: document is not defined
when running node scan.js
![No description](https://cdn.answeroverflow.com/1215072664465571961/image.png)
I have node
![No description](https://cdn.answeroverflow.com/1215072750859984977/image.png)
GeeksforGeeks
How to run Node Server ? - GeeksforGeeks
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Following these exact commands + sample code still gives me errors
maybe try changing the require to ES6 module import
import Quagga from 'quagga';
@Heitor What npm commands did you run?
just
npm i quagga
and before i started the project, with npm init -y
hmm
ive no idea lol
do you have node isntalled?