Cannot find module "@ionic-native/geolocation"

Hello All,

I am trying to resolve this issue since last 2 days but couldn’t find out the solution for it. To resolve this issue I tried following things

  • Re-Installed Ionic and Cordova.
  • Re configured every Ionic and Cordova.
  • import { Geolocation } from ‘@ionic-native/geolocation’; in module as well.

Please help me to resolve this issue.

I had similar problem. Try this:

  • delete geolocation plugin:
    ionic plugin re cordova-plugin-geolocation
  • then:
    npm install @ionic-native/core --save
    npm install @ionic-native/geolocation --save
    ionic plugin add corodva-plugin-geolocation

It works for me.
Official documentation:

5 Likes

Yup. This is correct.

1 Like

Hey Thanks…You saved my life :slight_smile:

Hi there,
I’m pretty sure that there is the answer but for me it doesn’t work 'cause of “UNMET PEER DEPENDECY”… I don’t really understand what to do, change my version ? how ?

See screenshot below :

sudo npm install @ionic-native/core --save

sudo npm install @ionic-native/geolocation --save

sudo ionic plugin add corodva-plugin-geolocation

Thanks in advance for your time & future replies

1 Like

Hey,

Do you get any solution for this?

Actually it didn’t cause any problem and I can see my google map and location with success. You can try to do something like : npm outdated
To check the version, and to compare it to the package.json file

Then you can try the : sudo npm update -g
It will update all the packages. Maybe it can help. In my case it didn’t change anything but it works so I’m not really worried anymore.

4 Likes

Thanks It is due to outdated npm :slight_smile:

1 Like

Cordova is spelt wrong. It should be cordova-plugin-geolocation.

1 Like

Thanks, this is true for this example, but I write it right after. it didn’t change the 2 other commands

Just to say that sudo npm update -g did the trick for me. Also, I put the following as a string so that anyone having this can find this topic.

Error: Registry returned 404 for GET on https://registry.npmjs.org/corodva-plugin-geolocation

EDIT: It finally didn’t help. Still getting Cannot find module "@ionic-native" (or "ionic-native")…

EDIT 2: Ok that’s because it must target a particular module like import { Geolocation } from '@ionic-native/geolocation'; !

Any time anybody mentions sudo, I’m going to keep plugging nvm. Friends don’t let friends run npm as root.

Sudo is on OSX (mac) to execute as administrator just needed to execute as administrator on windows.

@Skol check if you have properly install npm and ionic. Update the last version.

I know what sudo is. I see absolutely zero benefit and a huge downside to running npm with superuser privileges.

The reason for me is that when I install npm packages, it depends but many times it said that not all the things were installed properly.