While running "ionic cordova run android" command I am getting below error. Is there any way to get it fixed?


#1

WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of
date.
Error: ./src/pages/home/home.ts
Module not found: Error: Can’t resolve ‘angular’ in '/Users/aditaas/Documents/Paddy/Projects/IonicWorkspace/BeaconApp/src/pages/home’
resolve ‘angular’ in '/Users/aditaas/Documents/Paddy/Projects/IonicWorkspace/BeaconApp/src/pages/home’
Parsed request is a module


#2

Post your ionic info output and package.json content please.
Did you update something recently?
What does home.ts look like?


#3

Hi Sujan,

Required details :slight_smile:
ionic info :
global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v6.11.0
OS         : macOS Sierra
Xcode      : Xcode 8.2.1 Build version 8C1002
ios-deploy : not installed
ios-sim    : not installed
npm        : 3.10.10

package.json:
{
“name”: “BeaconApp”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “4.1.3”,
"@angular/compiler": “4.1.3”,
"@angular/compiler-cli": “4.1.3”,
"@angular/core": “4.1.3”,
"@angular/forms": “4.1.3”,
"@angular/http": “4.1.3”,
"@angular/material": “^2.0.0-beta.7”,
"@angular/platform-browser": “4.1.3”,
"@angular/platform-browser-dynamic": “4.1.3”,
"@ionic-native/core": “3.12.1”,
"@ionic-native/splash-screen": “3.12.1”,
"@ionic-native/status-bar": “3.12.1”,
"@ionic/storage": “2.0.1”,
“com.unarin.cordova.beacon”: “git+https://github.com/petermetz/cordova-plugin-ibeacon.git”,
“cordova-android”: “^6.2.3”,
“cordova-plugin-console”: “^1.0.5”,
“cordova-plugin-device”: “^1.1.4”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-statusbar”: “^2.2.2”,
“cordova-plugin-whitelist”: “^1.3.1”,
“ionic-angular”: “3.5.0”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“rxjs”: “5.4.0”,
“sw-toolbox”: “3.6.0”,
“uuid”: “^3.1.0”,
“zone.js”: “0.8.12”
},
“devDependencies”: {
"@ionic/app-scripts": “1.3.12”,
"@ionic/cli-plugin-cordova": “1.4.0”,
"@ionic/cli-plugin-ionic-angular": “1.3.1”,
"@types/angular": “^1.6.25”,
“angular-cli”: “^1.0.0-beta.28.3”,
“typescript”: “2.3.4”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“com.unarin.cordova.beacon”: {},
“cordova-plugin-console”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-statusbar”: {},
“cordova-plugin-whitelist”: {},
“ionic-plugin-keyboard”: {}
},
“platforms”: [
“android”
]
}
}

home.ts:

import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;

import * as angular from ‘angular’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})

export class HomePage
{

constructor(public navCtrl: NavController)
{
console.log(“test123”);
this.getDeviceLocation();
}

getDeviceLocation()
{
angular.module(‘starter’, [‘ionic’, ‘ngCordovaBeacon’])

.run(function($ionicPlatform) 
{
$ionicPlatform.ready(function() 
{
    // if(window.cordova && window.cordova.plugins.Keyboard) 
    // {
    //     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    // }
    // if(window.StatusBar) 
    // {
    //     StatusBar.styleDefault();
    // }
});

})

.controller(“ExampleController”, function($scope, $rootScope, $ionicPlatform, $cordovaBeacon)
{

$scope.beacons = {};

$ionicPlatform.ready(function() 
{

    $cordovaBeacon.requestWhenInUseAuthorization();

    $rootScope.$on("$cordovaBeacon:didRangeBeaconsInRegion", function(event, pluginResult) 
    {
        var uniqueBeaconKey;
        for(var i = 0; i < pluginResult.beacons.length; i++) 
        {
            uniqueBeaconKey = pluginResult.beacons[i].uuid + ":" + pluginResult.beacons[i].major + ":" + pluginResult.beacons[i].minor;
            $scope.beacons[uniqueBeaconKey] = pluginResult.beacons[i];
        }
        $scope.$apply();
    });

    $cordovaBeacon.startRangingBeaconsInRegion($cordovaBeacon.createBeaconRegion("estimote", "b9407f30-f5f8-466e-aff9-25556b57fe6d"));
  });
});

}
}


#4

This looks like an unholy mishmash of Ionic v1 and modern Ionic syntax that has no chance of working. There is absolutely no compatibility between the two, and you are going to have to completely start over deciding which way you want to go. What I see is not fixable.


#5

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#6

Hi Sujan,

Did not get your point can u pl come again ?..and code is already formatted there is no syntax error.


#7

Look at how you post looks here in the forum.
Not good.
Use the </> button over the input field to fix this.