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

ReferenceError: process is not defined #72

Closed
NunciosChums opened this issue Dec 17, 2024 · 2 comments
Closed

ReferenceError: process is not defined #72

NunciosChums opened this issue Dec 17, 2024 · 2 comments
Assignees

Comments

@NunciosChums
Copy link

// package.json
 "dependencies": {
    "@duckdb/node-api": "^1.1.3-alpha.7",
    "@duckdb/node-bindings-darwin-arm64": "^1.1.3-alpha.7",
}
// config.ts
import { DuckDBInstance } from '@duckdb/node-api';

let db: DuckDBInstance | null = null;

export const initDB = async () => {
  if (db) {
    return db;
  }
  db = await DuckDBInstance.create();
  return db;
};

Simply importing this from another file will result in an error.

+page.svelte
import { initDB } from '$lib/duckdb/config.js';
client:174  ReferenceError: process is not defined
    at node_modules/@duckdb/node-bindings/duckdb.js (duckdb.js:1:51)
    at __require2 (chunk-MTI3AIJG.js?v=d47ac081:18:50)
    at node_modules/@duckdb/node-api/lib/index.js (index.js:18:23)
    at __require2 (chunk-MTI3AIJG.js?v=d47ac081:18:50)
    at index.js:39:43

I also get this error when I put in code to attach a CSV file from https://github.com/duckdb-wasm-examples/sveltekit-typescript.

Uncaught (in promise) ReferenceError: _setThrew is not defined
    at invoke_viii (duckdb-browser-mvp.worker.js?type=module&worker_file:2:521001)
    at 09af586e
    at Module._duckdb_web_fail_with (duckdb-browser-mvp.worker.js?type=module&worker_file:2:513014)
    at Object.ccall (duckdb-browser-mvp.worker.js?type=module&worker_file:2:233490)
    at lt (duckdb-browser-mvp.worker.js?type=module&worker_file:2:795118)
    at Object.readFile (duckdb-browser-mvp.worker.js?type=module&worker_file:2:818571)
    at _duckdb_web_fs_file_read (duckdb-browser-mvp.worker.js?type=module&worker_file:2:170054)
    at 09af586e
    at 09af586e
    at 09af586e

  • macOS 15.2
  • Svelte 4
@jraymakers
Copy link
Contributor

Can you say more about what environment you're running the above code in?

Since you're using Svelte, a framework for frontend web applications, it seems likely you're trying to run this code in a browser environment. That isn't expected to work. This is a Node package, so it will only run in a Node environment. For running DuckDB in the browser, try DuckDB Wasm.

@jraymakers jraymakers self-assigned this Dec 17, 2024
@NunciosChums
Copy link
Author

OK. I will test it with DuckDB Wasm.

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

No branches or pull requests

2 participants