-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When creating the skeleton project with TypeScript and using @sveltejs/adapter-node, the build succeeds with warnings and fails to run when using node build.
Logs
Build warning
> Using @sveltejs/adapter-node
> .svelte-kit/node/index.js:18:31: warning: "import.meta" is not available in the configured target environment ("es2019") and will be empty
18 │ global.require = createRequire(import.meta.url);
╵ ~~~~~~~~~~~
tsconfig.json:6:12: note: The target environment was set to "es2019" here
6 │ "target": "es2019",
╵ ~~~~~~~~
> .svelte-kit/node/index.js:15792:40: warning: "import.meta" is not available in the configured target environment ("es2019") and will be empty
15792 │ const __dirname = dirname(fileURLToPath(import.meta.url));
╵ ~~~~~~~~~~~
tsconfig.json:6:12: note: The target environment was set to "es2019" here
6 │ "target": "es2019",
╵ ~~~~~~~~
✔ done
✨ Done in 2.01s.Run error
╰─$ node build
node:internal/process/esm_loader:74
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined
at new NodeError (node:internal/errors:363:5)
at createRequire (node:internal/modules/cjs/loader:1203:11)
at file:///Users/seth.corker/projects/mfe-example/blog/build/index.js:1566:18
at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5) {
code: 'ERR_INVALID_ARG_VALUE'
}To Reproduce
- Create a new sveltekit project with the skeleton template
- Add
@sveltejs/adapter-nodeas a dev dependency - Update
svelte.config.jsto use the adapter npm run buildnode build
Expected behavior
The server runs as expected when using node build
Stacktraces
Stack trace
node:internal/process/esm_loader:74
internalBinding('errors').triggerUncaughtException(
^
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received undefined
at new NodeError (node:internal/errors:363:5)
at createRequire (node:internal/modules/cjs/loader:1203:11)
at file:///Users/seth.corker/projects/mfe-example/blog/build/index.js:1566:18
at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5) {
code: 'ERR_INVALID_ARG_VALUE'
}Information about your SvelteKit Installation:
Diagnostics
System:
OS: macOS 11.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 1.07 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.3.0 - ~/.nvm/versions/node/v16.3.0/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 7.15.1 - ~/.nvm/versions/node/v16.3.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 91.0.4472.101
Firefox: 86.0.1
Firefox Developer Edition: 77.0
Safari: 14.1.1
npmPackages:
@sveltejs/adapter-node: next => 1.0.0-next.25
@sveltejs/kit: next => 1.0.0-next.114
svelte: ^3.34.0 => 3.38.2Severity
I found a workaround:
Update the tsconfig.json and change the target to match the target version specified in@sveltejs/adapter-node. I suspect es2020 should be used for SvelteKit and the adapter to work together as expected.
//tsconfig.json
{
"compilerOptions": {
- "target": "es2019"
+ "target": "es2020"
}
}bjon, half2me, Sebbl0508, saikat-das-yral and cupcakearmy
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working