Electron: The "path" argument must be of type string. Received type object

Viewed 1539

I'm trying to run Google Text-To-Speech in electron using the NodeJs Text To Speech Client Libary

I am able to use require('@google-cloud/text-to-speech'); within the main.js of my project (where the browser window is created)` but cannot run it within a script from within the page.

The error I get is the following:

Uncaught TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at validateString (internal/validators.js:112:11)
    at Object.basename (path.js:671:5)
    at GrpcClient.loadProto (path\to\project\node_modules\google-gax\build\src\grpc.js:117:29)
    at new TextToSpeechClient (path\to\project\node_modules\@google-cloud\text-to-speech\build\src\v1\text_to_speech_client.js:106:32)
    at file://path/to/project/scripts/speech/ttscli.js:7:16

from this code located in scripts/speech/ttscli.js

nodeIntegration is set to true, and scripts/speech/ttscli.js is used like so:

<script src="./scripts/speech/ttscli.js"></script>

Any assistance would be greatly appreciated

1 Answers

The "path" argument must be of type string. Received type object at validateString (internal/validators.js:112:11) at Object.basename (path.js:671:5)

That's an easy one: you aren't passing in a valid path (of type string).

<script src="./scripts/speech/ttscli.js"></script>

You don't mention your project structure – where is your renderer context relative to the path above? Do a console.log(__dirname)in your page script to see the page path and compare it to the path above.

Related