question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import locale in SvelteKit/NodeJS

See original GitHub issue

i tried the following combinations:

  • import { de } from ‘date-fns/locale/index.js’
  • import { de } from ‘date-fns/locale’
  • import { de } from ‘date-fns/esm/locale’
  • import { de } from ‘date-fns/esm/locale/index.js’

all of them bring this or a similar error: Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../node_modules/date-fns/locale/de' is not supported resolving ES modules imported from .../.svelte-kit/output/server/entries/pages/moral.svelte.js How can i get this to work please?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
faulandercommented, Feb 17, 2022

seems i got it to work with: import de from 'date-fns/locale/index.js'

0reactions
productdevbookcommented, Oct 6, 2022

esm problem

// m.mjs
import format from 'date-fns/esm/format/index.js'

console.log(format(new Date(), 'yyyy-MM-dd'))
(node:19584) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/private/tmp/date-fns-play/node_modules/date-fns/esm/format/index.js:1
import isValid from "../isValid/index.js";
Read more comments on GitHub >

github_iconTop Results From Across the Web

Svelte i18n Internationalization: how to localize a Svelte app
Add a new i18n.js file inside it with this code: import {. dictionary,. locale,. _. } from 'svelte-i18n';. function setupI18n({.
Read more >
A Step-by-Step Guide to Svelte Localization | Phrase
First, let's expose svelte-i18n's locale store through our own wrapper library. /src/services/i18n.js. import ...
Read more >
Loading data • Docs • SvelteKit
A +page.svelte file can have a sibling +page.js (or +page.ts ) that exports a load function, the return ... import * as db...
Read more >
Svelte Quick Tip: Adding basic internationalization (i18n) to ...
Tagged with svelte, i18n, javascript, webdev. ... App.svelte --> <script> import { t, locale, locales } from "./i18n"; // Create a locale ......
Read more >
Is it possible to access Svelte store from external js files?
Imagine pstats = {uid: 1, locale: 5} ... import { pstats} from './stores.js' export async function leave_locale() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found