欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ionic Error: Cannot find module "."

程序员文章站 2022-03-03 19:21:07
...

使用VScode开发ionic移动应用时,碰到如下错误:

Uncaught Error: Cannot find module "."
        at webpackMissingModule (index.js:3)
        at e.code (index.js:3)
        at Object.<anonymous> (index.js:9)
        at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
        at Object.690 (slide.transition.ts:67)
        at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
        at Object.495 (main.js:1885)
        at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)
        at Object.487 (notification-api.ts:6)
        at __webpack_require__ (bootstrap 62d6a5897825ac327001:54)

原因很怪异,只要在constructor中使用
NavController、ModalController等

就报错,经网上查询,终于看到了答案,原因就是在写NavController时,IDE提示从“ionic-angular/umd”导入,就直接用了,正是这个“umd”造成的错误,把从“ionic-angular/umd”导入

import { NavController } from 'ionic-angular/umd';

改为从“ionic-angular"导入

import { NavController } from 'ionic-angular';
就Ok了

具体原因不明,有了解的朋友请赐教!