SDK not working with typescript
# support
l
I have this starter TS app and getting the following error. Can someone please help?
Copy code
const Vapi = require("@vapi-ai/web").default;

// Replace with your actual Vapi public key
const vapi = new Vapi("public-key");

// Starting a call with an assistant ID
vapi.start("assistant id");
---here is the error---
Copy code
ReferenceError: window is not defined
    at new re (/Users/nischalj10/Documents/Codebases/vapi-demo/node_modules/@daily-co/daily-js/dist/daily.js:1:114444)
    at Function.value (/Users/nischalj10/Documents/Codebases/vapi-demo/node_modules/@daily-co/daily-js/dist/daily.js:1:188113)
    at Vapi.start (/Users/nischalj10/Documents/Codebases/vapi-demo/node_modules/@vapi-ai/web/dist/vapi.js:98:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^
v
@lordgpt It looks like you're trying to use a package that is intended for use in a browser environment within a Node.js (server-side) environment. The error message
ReferenceError: window is not defined
indicates that the code is trying to access the
window
object, which is only available in web browsers. To resolve this issue, you should ensure that you're running your Vapi code in a context where the
window
object is available, such as within a web page's script tag or a front-end JavaScript file that is bundled for browser use. If you're trying to use Vapi in a server-side context with Node.js, you'll need to check if Vapi provides a Node.js compatible package or an alternative way to interact with their API from the server side. If you need further assistance with this issue or if there's anything else I can help you with, please let me know!
You can continue this conversation by mentioning me in the message.
l
@User does vapi provide a node sdk?
s
@lordgpt you might be using web sdk in node environment? make sure to use sdk in web enviornment.
l
Is there a SDK for node?
@Shubham Bajaj
s
3 Views