0

While trying to run my project ionic cordova run Android it will show error:-

[13:07:43]  typescript error 
            Cannot find type definition file for 'hammerjs'. 

TypeError: Cannot read property 'replace' of null
    at Object.escapeHtml (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\util\helpers.js:253:10)
    at generateCodeBlock (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:187:77)
    at generateDiagnosticHtml (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:179:12)
    at Array.map (<anonymous>)
    at Object.printDiagnostics (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:15:39)
    at D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\transpile.js:158:34
    at new Promise (<anonymous>)
    at transpileWorker (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
    at Object.transpile (D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
    at D:\projects\hafele_latest\node_modules\@ionic\app-scripts\dist\build.js:109:82

I already added @types/hammerjs. I dont think it's a definition error. I think it is app-script error.

1
  • 1
    Can you share some more of your code? For example where is "hammerjs" imported? Commented May 27, 2021 at 7:53

2 Answers 2

1

Check if hammerjs is properly installed or not, in my case just running the following command resolved the issue

npm i @types/hammerjs
2
  • What is the explanation for this? What are @types/* and why are they needed?
    – Ade
    Commented Sep 23, 2022 at 16:43
  • 1
    @Ade. you can refer this stackoverflow.com/questions/37548066/… and the command npm i @types/hammerjs is to install hammerjs Commented Dec 10, 2022 at 14:36
0

Something like this happened to me and the issue was I didn't have

import 'hammerjs' ;

in my main.js file. Also, I use

import { BrowserModule, HammerModule } from '@angular/platform-browser';

in my component.ts

1
  • I already import 'hammerjs' in app-component.ts and in main.ts . Commented May 27, 2021 at 8:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.