0
votes

I have a problem installing nativescript modules to nativescript-vue with vue-cli-template. As mentioned on official website to I should install over npm and then clean the build. So I installed module:

  npm i --save nativescript-audio
  npm run clean

Then tried to implement first with "require":

 const audio = require('nativescript-audio');
 const player = new audio.TNSPlayer();

Then with "import":

import { TNSPlayer }  from "nativescript-audio";

But I constantly get same error:

Error: com.tns.NativeScriptException: Failed to find module: "nativescript-audio\options", relative to: app/tns_modules/

Complete log is here

Tried on Windows 7 and Ubuntu 16.04

Is this a problem in module or do I implement it wrong?

1

1 Answers

0
votes

As discussed in nativescript-vue Slack channel this is Windows problem that should be solved with webpack config for cli-template. As a workaround now I was able to import and use the plugin by changing its source code. For nativescript-audio I've opened "node_modules/nativescript-audio/audio.android.js" and changed ./ in path to nativescript-audio/:

__export(require("nativescript-audio/options"));
__export(require("nativescript-audio/android/player"));
__export(require("nativescript-audio/android/recorder"));

Then npm run clean and npm run watch:android and it worked