Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues to run with Node #483

Open
nicolaslevy opened this issue Nov 26, 2024 · 1 comment
Open

Issues to run with Node #483

nicolaslevy opened this issue Nov 26, 2024 · 1 comment

Comments

@nicolaslevy
Copy link

When building I'm having issues to make it work with Node.

Example:

import { VASTClient } from '../../dist/vast-client-node.js';

const vastClient = new VASTClient();

async function parseSimpleInline() {
    const parsedVast = await vastClient.get("https://statics.dmcdn.net/h/html/vast/simple-inline.xml");
    // eslint-disable-next-line no-console
    console.log(parsedVast);
}

await parseSimpleInline();

In particuar:
Looks like there is a window when using Node

> node index.js

/home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/vast-client-node.js:2807
      throw new Error(data.error);
            ^

Error: ReferenceError: window is not defined
    at Fetcher.fetchVAST (/home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/vast-client-node.js:2807:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.18.0

And after fixing that issue, I had otehr issue with XMLDom and Rollup: xmldom/xmldom#316

> node index.js

node:internal/modules/cjs/loader:1225
  const err = new Error(message);
              ^

Error: Cannot find module './dom'
Require stack:
- /home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/chunks/xmldom-ac2d7d04.js
- /home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/vast-client-node.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/chunks/xmldom-ac2d7d04.js:3:11)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/chunks/xmldom-ac2d7d04.js',
    '/home/nicolas/Develop/workspace_summer2025/vast-client-js/dist/vast-client-node.js'
  ]
}
@nicolaslevy
Copy link
Author

nicolaslevy commented Nov 26, 2024

PR with fixes and a Node example to test with: #484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant