Cannot find type definition file for '@types'

Hi,

I am trying to build my app with the --prod flag.

ionic cordova build android --verbose --prod

However, when I do, I get the error:

typescript error 
            Cannot find type definition file for '@types'. 

[17:12:58]  ionic-app-script task: "build" 
[17:12:58]  Error: Failed to transpile TypeScript 
Error: Failed to transpile TypeScript

The app builds fine in release, but not prod.

Any ideas would be appreciated.

Are you missing @types altogether on your project?

I have the same error now, but yesterday the build --prod was working :frowning:

Same error here… we changed nothing and this error popped up on friday :confused:

Hi,

ionic-app-script was recently updated producing this error.

As a workaround, you can lock its version in your package.json to the last working one:

"@ionic/app-scripts": "3.2.3",

12 Likes

Thank you! That solved my error! :hugs:

Ah, great thanks. This has sorted the issue. Shame the package testing isn’t up to scratch…

Noting that it won’t work globally, so npm i @ionic/app-scripts@3.2.3 only should work =)

2 Likes

it worked for me.
the problems i spent days on, solved! thank you

just editing the package.json didn’t change anything.
i ran npm i @ionic/app-scripts@3.2.3 command and it solved.
thanks to @luciojb

Better still, you can use the latest app scripts still if you add this to your tsconfig.json file:

{
  "compilerOptions": {
    ...
    "types": [
      "node"
    ]
  },
  ...
}

This might depend on your project @types but give it a go, worked for me.

2 Likes

thanks it works fine

Gracias esto resolvio mi problema, no olviden luego de actualizar el packge.json hacer npm install

Think this is the way to go. It worked for me without locking to an older version of app-script

1 Like