Runtime Error: Cannot find module "leaflet.awesome-markers" Ionic 3

jmarks

I'm adding Font Awesome markers to an Ionic 3 application using Leaflet that can successfully display Leaflet's built-in markers, but when I attempt to import the leaflet.awesome-markers module, ionic serve reports a runtime error saying it cannot find the module leaflet.awesome-markers.

One suggestion I've followed is to remove the node_modules directory and let npm re-install everything. This didn't change the results.

Output of ionic info:

cli packages: (/home/jett/git/mobiLoc/node_modules)

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.2.1

System:

Android SDK Tools : 26.0.2
Node              : v7.10.0
OS                : Linux 4.4
npm               : 4.2.0 

From package.json:

"@types/leaflet": "^1.2.0",
"@types/leaflet.awesome-markers": "^2.0.4",
"leaflet": "^1.2.0",
"leaflet.awesome-markers": "^2.0.4",
"typescript": "2.3.4"

Relevant code:

import * as L from "leaflet";
import "leaflet.awesome-markers";

private issueIcon: L.AwesomeMarkers.Icon;

this.issueIcon = L.AwesomeMarkers.icon({
  icon: 'heart-broken',    /* Heart with a crack */
  markerColor: 'red',
  prefix: "fa"
});

I'm new to both 1) Type Script and 2) debugging imports of 3rd-party modules that rely on type definitions. However, this doesn't appear to be a problem with resolving types -- my IDE is able to recognize the types defined within the leaflet.awesome-markers file. No compile/transpile errors/warnings either.

Because there are no compile-time problems, this appears to rule out a permissions problem on that module, but I've checked that all node_modules are installed local to the project and have the same permissions throughout the directory.

Interested in other approaches to debugging this.

jmarks

I don't fully understand how npm or my IDE is resolving imports, but I did stumble across a command that provided far more detail regarding the attempt to resolve the import. To get the extra detail, I used

npm run build

instead of

ionic serve

The npm run build command provided details of the various paths and extensions it was trying to use when resolving this line:

import "leaflet.awesome-markers";

I found the build was able to resolve this file once I changed the import statement to the location of the actual .js file:

import "leaflet.awesome-markers/dist/leaflet.awesome-markers";

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Ionic 2 - Runtime error Cannot find module "."

Ionic => Runtime error: Cannot find module "."

Runtime Error Cannot find module "ionic-native" IONIC 2

IONIC 2 - Runtime Error. Cannot find module “ionic-native”

Ionic3 - Uncaught Error: Cannot find module '.'

Runtime Error: Cannot find module "./config"

Runtime Error: error TS2307: Cannot find module 'leaflet'

Leaflet Awesome Markers - Balloons not showing

Cannot find module "d3" error is displayed after i upgraded my project from ionic 2 to ionic 3

Error: Cannot find module "angularfire2/database-deprecated" appmodule ionic 3, Angularfire2

Babel - Error: Cannot find module 'babel-runtime/helpers/typeof'

RollupJS `resolve failed: Error: Cannot find module 'babel-runtime'`

meteor Error: Cannot find module '@babel/runtime/helpers/builtin/interopRequireDefault'

Runtime Error : Cannot read property 'title' of undefined (Ionic 3)

Error: "Cannot find module" when cloning Ionic 4 component with StencilJS

Ionic Uncaught Error: Cannot find module "." when importing a service provider

Error: Cannot find module '@ionic/app-scripts'

Error: Cannot find module "rxjs/operators" in Ionic Angular

Error: Cannot find module 'symbol-observable' in Ionic 4

Ionic build error Cannot find module './scheduler/Action'

Ionic 3: Build in “prod” mode: Cannot find module “.”

Ionic 3 Angular 4 Cannot find module `jsonwebtoken`

Ionic Cordova Build prod: Cannot find module “.” - Typescript version >3

Error: Cannot find module './'

Using Leaflet.awesome-markers with Rails

In MVC .net project im getting error as "JavaScript runtime error: Error: Cannot find module "moment" "

error TS2307: Cannot find module '@ionic-native/date-picker/ngx' in ionic 4

Ionic 4 / Angular Routing: ERROR Error: Uncaught (in promise): Error: Cannot find 'EventHomePageModule' in './home/home.module'

Raspberry Pi 4: Error: Cannot find module 'sqlite3'