quaggaJS: Could not find a declaration file for module 'quagga'.

I want to add quagga to React and when I import it with import Quagga from "quagga"; I get:

Could not find a declaration file for module 'quagga'. '___path___/node_modules/quagga/lib/quagga.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/quagga` if it exists or add a new declaration (.d.ts) file containing `declare module 'quagga';`ts(7016)

npm i --save-dev @types/quagga is not possible because ‘@types/quagga@latest’ is not in the npm registry. ``declare module ‘quagga’;` is not possible in vanilla JS as I know.

About this issue

Most upvoted comments

I have the same error, I use React with Typescript. And I fixed it with the ignore tag :

// @ts-ignore import Quagga from 'quagga';

I did not know this library have a new version in https://github.com/ericblade/quagga2 with quagga2 work for me thanks!

i’m guessing that your tsconfig types setting is messed up somehow

In Visual Studio Code

I‘m adding import quagga from "quagga"; and then there is the issue

I never ever used typescript. So I don’t have a tsconfig.json file.

I use npx create-react-app barcode what creates a react app without typescript . Then I added Quagga with npm install quagga. I startet React with npm start. I open the App.js, added import quagga from "quagga"; and then I have that issue.

So there is no typescript and no modification at all. The import is the only change that exists.