简体   繁体   English

离子2:未捕获的ReferenceError:未定义require

[英]ionic 2:Uncaught ReferenceError: require is not defined

when i run my app in chrome://inspect with this command ionic run android i have this error 当我在chrome中运行我的应用程序时://使用此命令离子运行android我有这个错误

Uncaught ReferenceError: require is not defined 未捕获的ReferenceError:未定义require

在此输入图像描述

in addition, i tried in android emulator i see also blank page. 另外,我试过在android模拟器中我也看到了空白页面。 just want to notice some things: 只是想注意一些事情:

1. in web browser(when i run "ionic serve") and in ionic-view app of ionic 2 i can see the app and it works fine. 1.在网络浏览器中(当我运行“离子服务”)和离子2的离子视图应用程序我可以看到应用程序,它工作正常。

2.i tried another app and it works fine without any error. 2.i尝试了另一个应用程序,它没有任何错误工作正常。

If you using : 如果您使用:

let variableName = require("LibraryName");

Than remove that and try this : 比删除它并试试这个:

import * as variableName from "LibraryName";

or you can read https://github.com/driftyco/ionic/issues/8356 where 'require not defined' also got solved. 或者你可以阅读https://github.com/driftyco/ionic/issues/8356其中'require not defined'也得到了解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM