'Why am I unable to import an exported array in my script? Getting [ERR_MODULE_NOT_FOUND]: Cannot find module error

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 83lynx