npm run build fails
fractalf opened this issue · comments
Any idea how to fix this?
> Using svelte-adapter-deno
✘ [ERROR] Could not resolve "./deps.ts"
.svelte-kit/deno/index.js:1:56:
1 │ import { dirname, fromFileUrl, join, Application } from './deps.ts';
╵ ~~~~~~~~~~~
✘ [ERROR] Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/api/players.js:2:7:
2 │ import "better-sqlite3";
╵ ~~~~~~~~~~~~~~~~
The "main" field here was ignored. Main fields must be configured explicitly when using the
"neutral" platform.
node_modules/better-sqlite3/package.json:11:2:
11 │ "main": "lib/index.js",
╵ ~~~~~~
You can mark the path "better-sqlite3" as external to exclude it from the bundle, which will
remove this error.
✘ [ERROR] Could not resolve "better-sqlite3"
.svelte-kit/output/server/chunks/db-2acc2369.js:1:21:
1 │ import Database from "better-sqlite3";
╵ ~~~~~~~~~~~~~~~~
The "main" field here was ignored. Main fields must be configured explicitly when using the
"neutral" platform.
node_modules/better-sqlite3/package.json:11:2:
11 │ "main": "lib/index.js",
╵ ~~~~~~
You can mark the path "better-sqlite3" as external to exclude it from the bundle, which will
remove this error.
✘ [ERROR] Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/players.js:2:7:
2 │ import "better-sqlite3";
╵ ~~~~~~~~~~~~~~~~
The "main" field here was ignored. Main fields must be configured explicitly when using the
"neutral" platform.
node_modules/better-sqlite3/package.json:11:2:
11 │ "main": "lib/index.js",
╵ ~~~~~~
You can mark the path "better-sqlite3" as external to exclude it from the bundle, which will
remove this error.
✘ [ERROR] Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/index.js:2:7:
2 │ import "better-sqlite3";
╵ ~~~~~~~~~~~~~~~~
The "main" field here was ignored. Main fields must be configured explicitly when using the
"neutral" platform.
node_modules/better-sqlite3/package.json:11:2:
11 │ "main": "lib/index.js",
╵ ~~~~~~
You can mark the path "better-sqlite3" as external to exclude it from the bundle, which will
remove this error.
✘ [ERROR] Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/games.js:2:7:
2 │ import "better-sqlite3";
╵ ~~~~~~~~~~~~~~~~
The "main" field here was ignored. Main fields must be configured explicitly when using the
"neutral" platform.
node_modules/better-sqlite3/package.json:11:2:
11 │ "main": "lib/index.js",
╵ ~~~~~~
You can mark the path "better-sqlite3" as external to exclude it from the bundle, which will
remove this error.
> Build failed with 6 errors:
.svelte-kit/deno/index.js:1:56: ERROR: Could not resolve "./deps.ts"
.svelte-kit/output/server/chunks/db-2acc2369.js:1:21: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/api/players.js:2:7: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/games.js:2:7: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/index.js:2:7: ERROR: Could not resolve "better-sqlite3"
...
.svelte-kit/deno/index.js:1:56: ERROR: Could not resolve "./deps.ts"
.svelte-kit/output/server/chunks/db-2acc2369.js:1:21: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/api/players.js:2:7: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/games.js:2:7: ERROR: Could not resolve "better-sqlite3"
.svelte-kit/output/server/entries/endpoints/index.js:2:7: ERROR: Could not resolve "better-sqlite3"
...
at failureErrorWithLog (/home/..../app/node_modules/esbuild/lib/main.js:1603:15)
at /home/..../app/node_modules/esbuild/lib/main.js:1249:28
at runOnEndCallbacks (/home/..../app/node_modules/esbuild/lib/main.js:1162:65)
at buildResponseToResult (/home/..../app/node_modules/esbuild/lib/main.js:1247:7)
at /home/..../app/node_modules/esbuild/lib/main.js:1356:14
at /home/..../app/node_modules/esbuild/lib/main.js:666:9
at handleIncomingPacket (/home/..../app/node_modules/esbuild/lib/main.js:763:9)
at Socket.readFromStdout (/home/..../app/node_modules/esbuild/lib/main.js:632:7)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
Hm, it seems like bundling is failing due to including a Node dependency, do you have a Deno compatible alternative for the better-sqlite3
package you're using?
Ah right, it didn't occur to me that I'd have to use a "deno compatible" library. I guess I naively thought I could use any node lib with deno...
Anyway, I found this after a search, so I'll try that later when I'm back on my pet project track.
https://deno.land/x/sqlite@v3.4.0
Thanks :)
EDIT
Ofc the above deno package doesn't work, because the svelte-kit uses node to build the app... looks like I have a problem
@fractalf exactly, this adapter (and a few of the others geared towards serverless environments) suffer a bit from SvelteKit not being tied to a specific platform, in practice if you need platform-specific code you may have a hard time...
In any case, which error were you getting when trying to integrate with the Deno version of sqlite
? Were you using a custom deps.ts
file to inject it?
@jpaquim the problem was that I cannot "install" the deno sqlite lib with npm and
import { DB } from "https://deno.land/x/sqlite/mod.ts";
obviously fails when trying to build the app with node