diff --git a/documentation/docs/60-appendix/10-faq.md b/documentation/docs/60-appendix/10-faq.md index 1044a99527ae..ab880e3fec2e 100644 --- a/documentation/docs/60-appendix/10-faq.md +++ b/documentation/docs/60-appendix/10-faq.md @@ -12,19 +12,11 @@ See [the documentation regarding project types](project-types) for more details. ## How do I include details from package.json in my application? -You cannot directly require JSON files, since SvelteKit expects [`svelte.config.js`](./configuration) to be an ES module. If you'd like to include your application's version number or other information from `package.json` in your application, you can load JSON like so: +If you'd like to include your application's version number or other information from `package.json` in your application, you can load JSON like so: ```js /// file: svelte.config.js -// @filename: index.js -/// -import { URL } from 'node:url'; -// ---cut--- -import { readFileSync } from 'node:fs'; -import { fileURLToPath } from 'node:url'; - -const path = fileURLToPath(new URL('package.json', import.meta.url)); -const pkg = JSON.parse(readFileSync(path, 'utf8')); +import pkg from './package.json' with { type: 'json' }; ``` ## How do I fix the error I'm getting trying to include a package?