webpack捆绑包在后台时找不到模块

时间:2019-06-26 17:00:55

标签: javascript webpack nativescript

这是错误 Error: com.tns.NativeScriptException: Failed to find module: "../db", relative to: app/notifications/,但在webpack起作用之前,但是当应用程序在后台从服务器发出通知时,捆绑会中断相对路径。如果我使用旧版构建,则可以运行,但webpack击败了我!

试图改变相对路径是行不通的!

这是 NotificationIntentService.js ,其中需要后台通信(实时通知和消息)所需的模块

    onHandleIntent: function (intent) {
        var action = intent.getAction();
        if ("ACTION_START" == action) {
            processStartNotification();
        }
  android.support.v4.content.WakefulBroadcastReceiver.completeWakefulIntent(intent);
    }
});
const db=require("../db")
var LocalNotifications_1= require("nativescript-local-notifications");
var Vibrate = require("nativescript-vibrate").Vibrate;
var vibrator = new Vibrate();
var color_1 = require('tns-core-modules/color');
var dialogs_1 = require("tns-core-modules/ui/dialogs");
var model=require("../view");
var frameModule = require("tns-core-modules/ui/frame");
 model.checkStatus()
var io=require('../connection').io;
var iD=0
function processStartNotification() {
    // Do something. For example, fetch fresh data from backend to create a rich notification?
    var utils = require("tns-core-modules/utils/utils");
    var context = utils.ad.getApplicationContext();
    var ID=0;
}

function getDeleteIntent(context) {
        var intent = new android.content.Intent(context, com.tns.broadcastreceivers.NotificationEventReceiver.class);
        intent.setAction("ACTION_DELETE_NOTIFICATION");
        return android.app.PendingIntent.getBroadcast(context, 0, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
}

期望在后台(当应用关闭时)设置警报并收听服务器,但webpack无法评估模块路径

System.err: 
System.err: Error calling module function 
System.err: 
System.err: Error: com.tns.NativeScriptException: Failed to find module: "../db", relative to: app/notifications/
System.err:     com.tns.Module.resolvePathHelper(Module.java:146)
System.err:     com.tns.Module.resolvePath(Module.java:55)
System.err:     com.tns.Runtime.runModule(Native Method)
System.err:     com.tns.Runtime.runModule(Runtime.java:624)
System.err:     com.tns.Runtime.createJSInstance(Runtime.java:730)
System.err:     com.tns.Runtime.initInstance(Runtime.java:712)
System.err:     com.tns.notifications.NotificationIntentService.onCreate(NotificationIntentService.java:33)
System.err:     android.app.ActivityThread.handleCreateService(ActivityThread.java:3191)
System.err:     android.app.ActivityThread.-wrap5(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     android.os.Looper.loop(Looper.java:154)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
System.err: File: "<unknown>, line: 1, column: 265
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/com.MalaChat.aio/files/app/notifications/NotificationIntentService.js', line: 11, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err: 

0 个答案:

没有答案