Fixing requireCordovaModule error
by Sam
After I executed cordova prepare android
, I was prompted to update the cordova version to 9.0. So, I updated it by executing npm i -g cordova
:
When the version is already 9.0, this error occured:
Using "requireCordovaModule" to load non-cordova module "path" is not supported.
Instead, add this module to your dependencies and use regular "require" to load it.
Solution
$ npm uninstall -g cordova
Let us first uninstall the cordova framework.
$ npm cache clean --force
Make sure that the cache is clean after uninstalling.
$ npm install -g cordova@VERSION_NUMBER
It is now time to install the previous. To check the version number, you have to open
package.json
and search for cordova inside the dependencies.
If you have any question, don’t hesitate to comment below.