Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack warning: Can't resolve './locale' #6092

Open
Aston13 opened this issue Jan 24, 2023 · 7 comments
Open

Webpack warning: Can't resolve './locale' #6092

Aston13 opened this issue Jan 24, 2023 · 7 comments

Comments

@Aston13
Copy link

Aston13 commented Jan 24, 2023

WARNING in ./node_modules/@elsa-workflows/elsa-workflows-studio/dist/esm/moment-799f997a.js 2096:12-46
Module not found: Error: Can't resolve './locale' in 'C:\Repos...\node_modules@elsa-workflows\elsa-workflows-studio\dist\esm'

function loadLocale(name) {
    var oldLocale = null,
        aliasedRequire;
    // TODO: Find a better way to register and load all the locales in Node
    if (
        locales[name] === undefined &&
        typeof module !== 'undefined' &&
        module &&
        module.exports &&
        isLocaleNameSane(name)
    ) {
        try {
            oldLocale = globalLocale._abbr;
            aliasedRequire = require;
            aliasedRequire('./locale/' + name);
            getSetGlobalLocale(oldLocale);
        } catch (e) {
            // mark as not found to avoid repeating expensive file require call causing high CPU
            // when trying to find en-US, en_US, en-us for every format call
            locales[name] = null; // null means not found
        }
    }
    return locales[name];
}

Seems related to a previously fixed issue #4519

@baphony
Copy link

baphony commented May 16, 2023

Hi,
I have the same issue, using version 2.29.1

@nicolasopt
Copy link

nicolasopt commented Aug 8, 2023

Hi,
I tried many version from 2.24.0 to latest and get same issue too.
image
image

I don't think a popular dependency has regression from many versions long time ago. #4519

@Aston13
Copy link
Author

Aston13 commented Aug 8, 2023

I added a resolve to the webpack config to make this go away

resolve: { extensions: ['.ts', '.js', '.vue', '.json'], alias: { './locale': 'moment/locale', } },

@panda6412
Copy link

I also facing this problem in v2.29.4, any idea ?

@dimaslanjaka
Copy link

i was changed aliasesRequire in moment/min/moment-with-locales.js from

            require('./locale/' + name);
            // because defineLocale currently also sets the global locale, we
            // want to undo that for lazy loaded locales

to

            require('moment/locale/' + name);
            // because defineLocale currently also sets the global locale, we
            // want to undo that for lazy loaded locales

and now works without error No Module ./locale while compiling and on production

@bunyamink
Copy link

bunyamink commented Oct 17, 2023

i was changed aliasesRequire in moment/min/moment-with-locales.js from

            require('./locale/' + name);
            // because defineLocale currently also sets the global locale, we
            // want to undo that for lazy loaded locales

to

            require('moment/locale/' + name);
            // because defineLocale currently also sets the global locale, we
            // want to undo that for lazy loaded locales

and now works without error No Module ./locale while compiling and on production

this resolve my issue.

OR

add these lines to webpack.mix.js

mix.webpackConfig({
	resolve: {
 		alias: {
            './locale': 'moment/locale'
		},
        extensions: ['.js']
	}
});

@dimaslanjaka
Copy link

dimaslanjaka commented Oct 18, 2023

OR

add these lines to webpack.mix.js

mix.webpackConfig({
	resolve: {
 		alias: {
            './locale': 'moment/locale'
		},
        extensions: ['.js']
	}
});

this works when no file locale.js or locale.ts in src folder webpack project or external module. Otherwise the module that required same filename (same import pattern) will throw errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants