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
'./locale' path not found in moment/src/lib/locale/locales.js #4505
Comments
I see this same warning when I use webpack to bundle up moment. Any idea when this error was introduced? |
I have the same warning using angular-cli any solution? |
Having the same issue. Do you know of any workarounds / fixes? |
Same issue - looks like a path issue with './locale' vs '../locale'. Is anyone looking into this bug? |
Looks like it's been the case for years, why they won't fix it I have no idea. I just ran into this as well when trying to use jsnext:main in webpack instead of main. My work-around to keep using jsnext:main in webpack for the other packages that have properly transpiled es6 code: use an alias to force webpack to use moment.js directly as it is specified in pkg.main
|
The above didn't work for me but following this tutorial helped fix it for me. |
Is there anything new about this? I'm using Laravel Mix... same thing here... |
I do
and that works. |
inside the webpack? I am thinking about how to do this with Laravel Mix.. |
@marcelogarbin oh sorry I haven't messed with Laravel since version 4. I apologize but .I don't know how to make it work with laravel mix. |
Just import like below and it's work : import moment from 'moment/moment'; |
@yaasinhamidi's solution did the trick |
Where should this line be put? |
Experiencing this same issue for the first time after updating to 2.25.0. I am also using Laravel Mix (note, i never experienced this issue on any previous versions). |
my workaround is to get back to 2.24.0 |
I am facing the same issue after updating |
Until it is fixed, rolling back to v2.24.0 solves this issue. |
Rolling back to v.2.24.0 worked for me as well. |
for anyone else experiencing this issue, i had to also force the versions of moments that other packages in my using yarn, adding this line to package.json sorted things for me
|
Hello Guys! In the above comments i saw the final solution. Reason: Solution:
Step 2: If you are using yarn please add resolutions in your package.json file like this Thank You. |
Even if you have, following block. The package-lock.json will create a new version i.e. 2.5.1. So change it to "moment": "2.24.0" till the issue is addressed. |
i rolled back to 2.24.0 but still having same warning while using node |
It's weird I started getting this error today after re installing dependencies, the suggested fix of ignoring the locale plugins with webpack didn't work. What worked was leaving the version fixed at 2.24.0 as suggested by @sachins81 . I wonder if something relevant changed in recent commits? @ichernev |
|
I just rolled back to "^2.18.1" and everything seems working fine |
Same issue using react, moment isnt a dependancy of my project so I can't roll it back |
Mediocre fix, if someone doesn't have antd as dependency directly. I've encountered the same problem but I don't have momentjs in dependencies. But antd does.
|
I have the same issue in my React app which, for some reason, started to show up out of the blue. I've been using I then tried
The only saving grace is that my React app, at least, compiles and runs fine. |
I have the same issue with create-react-app (typescript template) too.I tried |
@devayarhlaine I have post a temporary solution in above comments please check it. Its was a moment new version issue. |
Same s above: Got this error when upgrading from angular 8 to angular 9.1. |
For those using the command "yarn create react-app ", the fix is to edit node_modules/react-scripts/config/webpack.config.js to add the alias like below.
Insert the above line into the alias block at line number 311.
Another way to solve this is to replace moment.js with Day.js. Follow the instructions in this url to use react-app-rewired >> https://ant.design/docs/react/use-with-create-react-app. Modify package.json according to the instruction. Then create a config-overrides.js in the root folder like below. This has the benefit of shrinking the js from 231.11kb to 11.11kb according to this https://github.com/ant-design/antd-dayjs-webpack-plugin.
|
Fantastic fix!!! |
Worked for me |
Yup, removing |
I have fix this error, at least for me. I went to node_modules/moment/src/lib/locale/ To be honest, I copied the original line and commented just above, if in the future an error shows up. If it helps, thumbs up. This kind of errors are the worse... |
Running `ng build` after updating all the packages revealed a problem with just one: moment going from 2.24.0 => 2.25.1 ``` WARNING in ./node_modules/moment/src/lib/locale/locales.js Module not found: Error: Can't resolve './locale' in '/Users/msorens/code/go/src/github.com/chef/automate/components/automate-ui/node_modules/moment/src/lib/locale' ``` The issue was encountered by many: moment/moment#4505 (comment) The particular comment in the thread I linked to has a suggested workaround, though I had to modify it to get it to work. Using it exactly as is in that thread generated this error on every `moment` use: ``` This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. ``` But I found that I could retain `import *...` instead of `import moment...` to solve the original issue without encountering the follow-up issue. This commit, then, makes that simple change in 57 files. One file imported `moment` slightly differently so adjusted that as well. Signed-off-by: michael sorens <msorens@chef.io>
Having the same problem, reverted to 2.24 until a fix is available. I can't edit the module files, as i'm building on an automatic server, so waiting for an official release. |
I have the same issue with 2.24 and 2.25.1 version When I open browser console, I see this error: |
Running `ng build` after updating all the packages revealed a problem with just one: moment going from 2.24.0 => 2.25.1 ``` WARNING in ./node_modules/moment/src/lib/locale/locales.js Module not found: Error: Can't resolve './locale' in '/Users/msorens/code/go/src/github.com/chef/automate/components/automate-ui/node_modules/moment/src/lib/locale' ``` The issue was encountered by many: moment/moment#4505 (comment) The particular comment in the thread I linked to has a suggested workaround, though I had to modify it to get it to work. Using it exactly as is in that thread generated this error on every `moment` use: ``` This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. ``` But I found that I could retain `import *...` instead of `import moment...` to solve the original issue without encountering the follow-up issue. This commit, then, makes that simple change in 57 files. One file imported `moment` slightly differently so adjusted that as well. Signed-off-by: michael sorens <msorens@chef.io>
We are having the same issue with moment 2.22 |
Where should this line be put? |
In the file that you want use momentjs on ecmascript like below:
|
2.25.3 should fix this issue. |
This alias with the WebPack config fixes an issue for me:
|
If you are using moment-timezone: |
i fix this with this:
it works, and the locale is set to 'pt-br', and all others languages works too. |
I found that there is something wrong with the function below
aliasedRequire('./locale/' + name);
, should it be../locale/
?The text was updated successfully, but these errors were encountered: