When attempting to use the Vonage SDK with TypeScript, a syntax error is encountered during compilation. The error specifically points to the unexpected token '.' in the client.js file of the Vonage library.
// Create Vonage client
this.client = new Vonage(new Auth({
apiKey: sms.smsKeyVonage,
apiSecret: sms.smsSecretVonage,
}));
// Also tried with
this.client = new Vonage(new Auth({
apiKey: sms.smsKeyVonage,
apiSecret: sms.smsSecretVonage,
}), undefined);
// later in the code when I try to send an sms
this.vonageClient.sms.send({ to: phone, from: sms.smsFrom, text: message });
During compilation, the following error is thrown:
/node_modules/@vonage/server-client/dist/client.js:46
restHost: options?.restHost || 'https://rest.nexmo.com',
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (***/node_modules/@vonage/server-client/dist/index.js:18:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (***/node_modules/@vonage/accounts/dist/accounts.js:4:25)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (***/node_modules/@vonage/accounts/dist/index.js:4:18)
line 41-53 in client.js -> /node_modules/@vonage/server-client/dist/client.js:46
Current Behavior
When attempting to use the Vonage SDK with TypeScript, a syntax error is encountered during compilation. The error specifically points to the unexpected token '.' in the client.js file of the Vonage library.
During compilation, the following error is thrown:
line 41-53 in client.js -> /node_modules/@vonage/server-client/dist/client.js:46
Context
My tsconfigs in a mono-repo:
core
backend
Your Environment
Thanks in advance!