Skip to content

Error: com.tns.NativeScriptException: Failed to find module: "./workers/enable-bluetooth", relative to: app// #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
Mauoanel opened this issue Jan 5, 2021 · 6 comments

Comments

@Mauoanel
Copy link

Mauoanel commented Jan 5, 2021

Hi everyone, I'm trying to use a thermal printer but I keep on getting the below error.

The application can connect to the bluetooth printer.
I've also installed other applications from the playstore on my phone just to see if I can print on the thermal printer and they all can print however, when I use this lib, my application cannot print.

I have created a folder under *project/src/app/workers and also created files(enable-bluetooth.js, connect-printer.js)

  • Any ideas?

JS: Error Error: com.tns.NativeScriptException: Failed to find module: "./workers/enable-bluetooth", relative to: app//
JS: Printer found = {
JS: "portName": "A0:E6:F8:34:1E:99",
JS: "modelName": "XX706*"
JS: }
JS: Connect error Error: com.tns.NativeScriptException: Failed to find module: "./workers/connect-printer", relative to: app//
JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: Attempt to invoke interface method 'int HPRTAndroidSDK.IPort.WriteData(byte[], int)' on a null object reference
JS: push.../node_modules/nativescript-hprt/hprt.js.Hprt.horizontalLine(file: node_modules/nativescript-hprt/hprt.android.js:204:0)
JS: at webpackHotUpdate../app/home/home.component.ts.HomeComponent.printText(file: src/app/home/home.component.ts:138:18)
JS: at webpackHotUpdate../app/home/home.component.ts.HomeComponent.connect(file: src/app/home/home.component.ts:79:13)
JS: at HomeComponent(file: src/app/home/home.component.ts:63:13)
JS: at createClass(file: node_modules/@angular/core/fesm5/core.js:21158:0)
JS: at createDirectiveInstance(file: node_modules/@angular/core/fesm5/core.js:21027:0)
JS: at createViewNodes(file: node_modules/@angular/core/fesm5/core.js:29387:0)

@subhojit-me
Copy link
Contributor

facing the same issue. any update regarding this?

@subhojit-me
Copy link
Contributor

subhojit-me commented Feb 24, 2021

in hprt.android.js file on method Hprt.prototype.enableBluetooth the issue is getting generated from below mentioned line. its not getting the worker file while its there in the nativescript-hprt/workers folder

var enableBluetoothWorker = new Worker('./workers/enable-bluetooth');

@davorpeic
Copy link
Member

@subhojit-me @Mauoanel Did you guys follow docs? https://github.com/krushkamx/nativescript-hprt#working-with-workers it looks like there is webpack config missing, so your app is not copying files to the device

@subhojit-me
Copy link
Contributor

subhojit-me commented Mar 3, 2021

Hi @davorpeic after reading the docs, did these steps to use workers.

  1. added workers in app/workers
    worker files

  2. webpack.config.js
    plugins: [ // Define useful constants like TNS_WEBPACK new webpack.DefinePlugin({ 'global.TNS_WEBPACK': 'true', 'global.isAndroid': platform === 'android', 'global.isIOS': platform === 'ios', process: 'global.process' }), // Remove all files from the out dir. new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: itemsToClean, verbose: !!verbose }), // Copy assets new CopyWebpackPlugin([ ...copyTargets, { from: { glob: '**/*.jpg', dot: false } }, { from: { glob: '**/*.png', dot: false } }, // Rev SK { from: { glob: 'workers/**', dot: false } }, // End Rev SK ], copyIgnore), new nsWebpack.GenerateNativeScriptEntryPointsPlugin('bundle'), // For instructions on how to set up workers with webpack // check out https://github.com/nativescript/worker-loader new NativeScriptWorkerPlugin(), ngCompilerPlugin, // Does IPC communication with the {N} CLI to notify events when running in watch mode. new nsWebpack.WatchStateLoggerPlugin() ]

dont know the the dot: false can be an isue or not

@davorpeic
Copy link
Member

@subhojit-me Can you try adding app in path for workers in webpack config just to see if this solves the issue? { glob: 'app/workers/**', dot: false }

@subhojit-me
Copy link
Contributor

subhojit-me commented Mar 4, 2021

@davorpeic { glob: 'app/workers/**', dot: false } not working

Would like to share that version 0.9.6 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants