core icon indicating copy to clipboard operation
core copied to clipboard

'window is not defined' error when including the diffusion core module

Open ODonnellBBC opened this issue 7 months ago • 2 comments

We're getting the following error when attemping to use Diffuse on an upcoming project. I'm assuming this may be 'commonjs' / 'ESNext' module related?

Image

2025-05-09 15:18:06 ReferenceError: window is not defined 2025-05-09 15:18:06 at file:///opt/silver-client/node_modules/@diffusionstudio/core/dist/core.umd.js:13:1124 2025-05-09 15:18:06 at file:///opt/silver-client/node_modules/@diffusionstudio/core/dist/core.umd.js:13:178 2025-05-09 15:18:06 at file:///opt/silver-client/node_modules/@diffusionstudio/core/dist/core.umd.js:13:194 2025-05-09 15:18:06 at ModuleJobSync.runSync (node:internal/modules/esm/module_job:400:35) 2025-05-09 15:18:06 at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:427:47) 2025-05-09 15:18:06 at loadESMFromCJS (node:internal/modules/cjs/loader:1561:24) 2025-05-09 15:18:06 at Module._compile (node:internal/modules/cjs/loader:1712:5) 2025-05-09 15:18:06 at node:internal/modules/cjs/loader:1895:10 2025-05-09 15:18:06 at Object.require.extensions.<computed> [as .js] (/opt/silver-client/node_modules/ts-node/src/index.ts:1608:43) 2025-05-09 15:18:06 at Module.load (node:internal/modules/cjs/loader:1465:32)

import * as core from '@diffusionstudio/core';

ODonnellBBC avatar May 09 '25 14:05 ODonnellBBC

I'm assuming you're attempting to run it in node correct? Core is only supported in browser environments

k9p5 avatar May 10 '25 20:05 k9p5

and if you are using it in client and stll getting this error ( especially in nextjs) just use "use client"; should fixed this

RedWilly avatar May 20 '25 13:05 RedWilly