Require "tns-core-modules/application" error


#1
    const application = require("tns-core-modules/application");
    export default {
        data () {
            return {
                surprise: false,
            };
        },
        mounted(){
            console.log("****");
            console.log(application.android);
            console.log("****");
        },
    };

npm run watch:android

  • console display
Preparing project...
Project successfully prepared (Android)
Successfully transferred app.js.
Refreshing application...
Successfully synced application org.nativescript.application on device emulator-5554.
System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
System.err:
System.err: Error calling module function
System.err:
System.err: Error: com.tns.NativeScriptException: Failed to find module: "_tns-core-modules@3.4.1@tns-core-modules/application/application-common", relative to: app/tns_modules/
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:553)
System.err:     com.tns.Runtime.run(Runtime.java:545)
System.err:     com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
System.err:     android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
System.err:     android.app.ActivityThread.-wrap2(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
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


#2

Try,

const application = require("application");

#3

This way also can not, I use a NativeScript - vue, I try to write in NativeScript - vue, use the application can be successful, but according to the method of https://nativescript-vue.org/en/docs/getting-started/nativescript-plugins/ try many times, or put it in the launch, will be submitted to the top of js error!