0

I have a translations.ts file located at project/src/services/translations.js that exports the following array:

export const supportedLocales = ['en', 'es'];

And I am attempting to import it in generateStrings.mjs file which is located at project/src/scripts/generateStrings.mjs like this:

import { supportedLocales } from '../services/translations';

But I get an error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/User/Desktop/Projects/mobile/src/services/translations' imported from /Users/User/Desktop/Projects/mobile/src/scripts/generateStrings.mjs

My IDE couldn't automatically import the array either only in that specific file. I wonder if it is because the file has .mjs extension?

Onyx
  • 5,186
  • 8
  • 39
  • 86
  • Does this answer your question? [Why is Javascript module with ".js" file extension not found on import unless file extension is .mjs despite package "type" being "module"?](https://stackoverflow.com/questions/67851875/why-is-javascript-module-with-js-file-extension-not-found-on-import-unless-fi) – lusc May 20 '22 at 15:21
  • @lusc I imagine that is the problem, however, in my case just adding .js here import { supportedLocales } from '../services/translations.js'; didn't really do anything. – Onyx May 20 '22 at 15:32

1 Answers1

0

mistype, import from translationS, and file named translation.js without S at the end

83lynx
  • 111
  • 5
  • Sorry I mistyped that as I was writing the question, but in my code that mistake doesn't exist. – Onyx May 20 '22 at 15:21