Unexpected value ‘NativeHttpModule’ in Ionic 5

Fix - Unexpected value ‘NativeHttpModule’… Please add a @NgModule annotation.

I came across this one particular issue which stopped me from taking prod build. After hours of search and trial method this is how I resolved it.

First, upgrade your ionic-native-http-connection-backend module to 8.1.1 or above in your package json file.

Second, set ‘enableIvy’ as true in tsconfig json file.

Third and a general practice, update all your pipeable operators to their latest syntax and avoid using the deprecated syntax.

For example :

  1. do -> tap
  2. catch -> catchError
  3. switch -> switchAll
  4. finally -> finalize

Finally, take a production build of your favorite Ionic application using “ionic cap build android -- prod”.

This applies well to other npm modules as well (more or less) . Happy coding!

--

--