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

SyntaxError: Unexpected token 'export' #10

Closed
sonicjhon1 opened this issue May 19, 2023 · 2 comments
Closed

SyntaxError: Unexpected token 'export' #10

sonicjhon1 opened this issue May 19, 2023 · 2 comments

Comments

@sonicjhon1
Copy link
Contributor

Fails to run kysely-surrealdb on a new project. Minimal reproduction project.

import { Kysely } from "kysely";
import type { DB } from "./src/generated/kysely/types";
import { SurrealDatabase, SurrealDbWebSocketsDialect } from "kysely-surrealdb";
import Surreal from "surrealdb.js";

const db = new Kysely<SurrealDatabase<DB>>({
	dialect: new SurrealDbWebSocketsDialect({
		Driver: Surreal,
		hostname: "localhost:8080",
		namespace: "namespace",
		database: "name",
		username: "root",
		password: "root",
	}),
});

(async function () {
	if (db == null) {
		console.log("db is null");
	} else {
		console.log(await db.selectFrom("Chat").selectAll().execute());
	}
})();

Error:

pnpm run dev

> kysely-surreal@1.0.0 dev D:\SJ\Devs\Github\kysely-surreal
> pnpm dlx prisma generate && ts-node index.ts

../../../../.pnpm-store/v3/tmp/dlx-16396 |   +2 +
../../../../.pnpm-store/v3/tmp/dlx-16396 | Progress: resolved 2, reused 2, downloaded 0, added 2, done
Prisma schema loaded from prisma\schema.prisma

 Generated Kysely types (1.4.1) to .\src\generated\kysely in 12ms

D:\SJ\Devs\Github\kysely-surreal\node_modules\.pnpm\unws@0.2.2_ws@8.13.0\node_modules\unws\src\node.js:3
export { WebSocket }
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Object.require.extensions.<computed> [as .js] (D:\SJ\Devs\Github\kysely-surreal\node_modules\.pnpm\ts-node@10.9.1_@types+node@20.2.1_typescript@5.0.4\node_modules\ts-node\src\index.ts:1608:43)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Function.Module._load (node:internal/modules/cjs/loader:972:12)
    at Module.require (node:internal/modules/cjs/loader:1157:19)
    at require (node:internal/modules/helpers:119:18)
    at Object.<anonymous> (D:\SJ\Devs\Github\kysely-surreal\node_modules\.pnpm\surrealdb.js@0.7.2_ws@8.13.0\node_modules\surrealdb.js\src\library\WebSocket\node.ts:2:1)
 ELIFECYCLE  Command failed with exit code 1.
@sonicjhon1
Copy link
Contributor Author

sonicjhon1 commented May 19, 2023

After some digging, it turns out that this issue is caused by a recent update in surreal.js library.
A PR is currently open on the unws dependency, as soon as the PR is merged this issue would be solved.

Closing this issue too, as it wasn't caused by this library.
(Sorry if I had wasted your time again..)

@igalklebanov
Copy link
Owner

igalklebanov commented May 19, 2023

Hey 👋

You've not wasted my time. Thank you!
I'm looking into various breaking changes in recent surrealdb image & client library.

v0.7.1 has been published with a stricter peer dependency on surrealdb.js for now.

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