cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with nativescript plugin when deploying

Facundo_Quevedo
Explorer
0 Kudos

Hi experts im trying to implement a Audio recorder for my aplication with this plugin

@nativescript-community/audio
but when i tried to import the plugin i had this error when deploying the application.
 
I alredy declare the plugin in the  "mdk.bundlerExternals"
 
/**
 * Describe this function...
 * @Param {IClientAPI} clientAPI
 */

import * as Recorder from "@nativescript-community/audio"
import { TNSRecorder } from '@nativescript-community/audio';
export default function RecordAudio(clientAPI) {
 
let recorder = new TNSRecorder();
let isRecording = false;
  if (!isRecording) {
    // Start recording
    const options = {
      filename: 'testrecording.mp3',
      errorCallback: function(err) {
        console.log('error recording', err);
      }
    };

    recorder.start(options).then(() => {
      console.log('recording started');
      isRecording = true;
      // Show message
      return clientAPI.executeAction({
        'Name': '/Recorder/Actions/Messages/CustomMessage.action',
        'Properties': {
          'Message': `Grabando`
        }
      });
    }, (err) => {
      console.log('error starting', err);
    });
  } else {
    // Stop recording
    recorder.stop().then(() => {
      console.log('recording stopped');
      isRecording = false;
      // Show message
      return clientAPI.executeAction({
        'Name': '/Recorder/Actions/Messages/CustomMessage.action',
        'Properties': {
          'Message': `Grabación terminada`
        }
      });
    }, (err) => {
      console.log('error stopping', err);
    });
  }
}



Command failed: "/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/bin/mdkcli.sh" bundle --nativescript-project "/home/user/projects/Recorder/.build/Recorder/.build" --seam-project "/home/user/projects/Recorder/.build/Recorder" --externals nativescript-audio --filters /Recorder/Web/ /Recorder/Recorder/Web --bundle-zip-target-path "/home/user/projects/Recorder/.build/Recorder/.build" --bundle-definition-path "out/Recorder" --devtool "source-map" --create-bundle --ts-target "es6" --wmf
MDK Bundler - failed to create bundle
asset bundle.js 79.4 KiB [emitted] (name: bundle.js) (id hint: vendors) 1 related asset
asset dummy.js 78.3 KiB [emitted] (name: dummy.js) 1 related asset
runtime modules 4.91 KiB 10 modules
modules by path ./build.definitions/Recorder/ 30.4 KiB
javascript modules 30.4 KiB 51 modules
json modules 64 bytes
./build.definitions/Recorder/jsconfig.json 52 bytes [built] [code generated]
./build.definitions/Recorder/Styles/Styles.light.json 12 bytes [built] [code generated]
modules by path ../../../../css-loader/dist/runtime/*.js 2.74 KiB
../../../../css-loader/dist/runtime/sourceMaps.js 505 bytes [built] [code generated]
../../../../css-loader/dist/runtime/api.js 2.25 KiB [built] [code generated]
container entry 42 bytes [built] [code generated]
./build.definitions/application-index.js 10.6 KiB [built] [code generated]
./build.definitions/Application.app 519 bytes [built] [code generated]
./build.definitions/tsconfig.json 397 bytes [built] [code generated]
./build.definitions/version.mdkbundlerversion 16 bytes [built] [code generated]

ERROR in ./build.definitions/Recorder/Rules/RecordAudio.js 8:0-57
Module not found: Error: Can't resolve '@nativescript-community/audio' in '/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/Recorder/Rules'
resolve '@nativescript-community/audio' in '/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/Recorder/Rules'
Parsed request is a module
using description file: /managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/package.json (relative path: ./out/Recorder/build.definitions/Recorder/Rules)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/Recorder/Rules/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/Recorder/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/unzipped/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/vscode/__dummy_node_modules__ doesn't exist or is not a directory
/managed-content/__dummy_node_modules__ doesn't exist or is not a directory
/__dummy_node_modules__ doesn't exist or is not a directory
@ ./build.definitions/application-index.js 49:36-78

webpack 5.88.0 compiled with 1 error in 438 ms
ModuleNotFoundError: Module not found: Error: Can't resolve '@nativescript-community/audio' in '/managed-content/vscode/unzipped/25__@ext-mdkvsc-npm-rel__mde-vscweb@4.2.13/extension/node_modules/@sap/mdk-tools/out/Recorder/build.definitions/Recorder/Rules'
undefined

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Could you share how exactly did you list the NS plugin as external reference in BAS settings?

I am able to deploy my MDK project with your rule after declaring the required information in BAS settings.

 

"mdk.bundlerExternals": [
"@nativescript-community/audio"
]
Facundo_Quevedo
Explorer
0 Kudos

Hi Jitendra, yes i list the ns plguin as an external reference in BAS settingsCaptura de pantalla 2024-03-25 083032.png

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
Are you still experiencing this issue?
Facundo_Quevedo
Explorer
0 Kudos
Yes, still trying to figure it out
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

How did you deploy the project to mobile services? Did you follow Right click Application.app > MDK: Deploy option and then selected Mobile Services?

Facundo_Quevedo
Explorer
0 Kudos
yes i richt click Application.app > MDK: Deploy option and the selected Mobile Services
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you try the following:

  • List the NPM modules in Remote location. (In the screenshot you shared, you have listed it in user settings. However, this should have worked for you though. It's working for me without any issue). Try deploying again.
    Jitendra_Kansal_0-1711520807646.png

     

  • If above doesn't work, create a new dev space. Import your project, list NPM module as per previous step and try deploying.
  • If you still see issues, please open a support ticket with all these details for further investigation. (refer this note).
Facundo_Quevedo
Explorer
0 Kudos
I listed the plugin in the remote extension and it work thank you.

Answers (0)