question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module “.” issue with Ionic 2

See original GitHub issue

Hi, I have the following issue while doing an ionic 2 serve command using TypedJSON :

Error: Cannot find module "."
    at webpackMissingModule (http://localhost:8100/build/main.js:82208:69)
    at METADATA_FIELD_KEY (http://localhost:8100/build/main.js:82208:147)
    at Object.<anonymous> (http://localhost:8100/build/main.js:82213:3)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:94414:86)

[...]

I can reproduce it with a simple app. Here are my steps :

//Installing last ionic version npm install -g ionic@latest cordova typescript

//Creating a new app ionic start test blank --v2

//Installing webpack support npm install @ionic/app-scripts@latest --save-dev

//Installing TypedJSON npm install typedjson-npm

//Installing typings typings install npm:typedjson-npm

I created a simple model :

import { JsonMember, JsonObject } from 'typedjson-npm';

@JsonObject
export class GeoJsonModel {

  @JsonMember
  type: string;

  public getType() {
    return this.type;
  }
}

And here is my home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { GeoJsonModel } from '../../models/geojson-model';
import { TypedJSON } from 'typedjson-npm';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {

    var geo= TypedJSON.parse('{ "type": "geojson"}', GeoJsonModel);

    console.log(geo instanceof GeoJsonModel);
    console.log(geo.getType());
  }
}

Based on #49 I added in tsconfig.json “module”: “commonjs” but it doesn’t seem to work. I’m probably doing something wrong.

Thank you for your help.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

16reactions
sekcommented, Jul 24, 2018

FYI: Visual Studio Code was putting “/umd” suffix in some auto-imports causing this error for me in an Ionic project - removed that and it was fine - see here: https://github.com/webpack/webpack/issues/4921#issuecomment-399934222

4reactions
Benny739commented, Jan 3, 2017

I got the same error, fixed it by importing the ts file: import { TypedJSON, JsonObject, JsonMember } from 'typedjson-npm/src/typed-json';

Maybe this should be added to the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Runtime Error - Cannot Find Module "." - Ionic Forum
I've tried backtracking, but I still haven't been able to find this issue. Anyone have any ideas of what could possibly be the...
Read more >
Ionic 2 - Runtime error Cannot find module "." - Stack Overflow
Just remove all imports that have /umd at the final. In my case, I changed: import { IonicPageModule } from 'ionic-angular/umd'; To: import...
Read more >
Cannot find module “.” after --prod --relase build in ionic 3 #4132
I am trying to make my prod build work I am getting this error Cannot find module "." at vendor.js:1 at vendor.js:1 at...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >
Cannot find module '@ionic-native/http/ngx'. - Reddit
Cannot find module '@ionic-native/http/ngx'. ... So, I have an old project of Ionic and I wanted to run it. So, I found out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found