使用Moment JS创建-React-App:找不到模块“./ locale” [英] Create-React-App with Moment JS: Cannot find module "./locale"

查看:190
本文介绍了使用Moment JS创建-React-App:找不到模块“./ locale”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网络应用程序上运行了 npm update ,现在 Moment JS 似乎失败了,并显示以下消息:

Just ran an npm update on my web application and now Moment JS appears to be failing with the following message:

Error: Cannot find module "./locale"
\node_modules\moment\src\lib\moment\prototype.js:1
> 1 | import { Moment } from './constructor';

我不确定在更新之前我的 Moment JS 的版本是什么但我的申请已经工作了几个月。

Not sure what version of Moment JS I had prior to my update, but my application has been working for months.

我创建了另一个反应应用并运行 npm安装时刻--save 并修改了源以显示时间并最终得到了上述相同的错误。

I created another react app and ran an npm install moment --save and modified the source to display the time and ended up with the same error described above.

不确定是否存在使用集成 Moment JS 的防故障方式Create-React-App 目前缺少弹出以自行管理webpack设置,但我真的不想这样做。其他人看到这些问题或取得成功?如果是这样的话,那么简短的写作就会有所帮助。

Not sure if there is a fail-proof way to integrate Moment JS using Create-React-App currently short of ejecting to manage the webpack settings myself, but I really don't want to do this. Anyone else seeing these issues or having success? If so, a short write up would go along way to helping out.

推荐答案

看来这已被确定为问题所在 Moment JS 版本2.19。如果你已经升级到2.19运行 npm install moment@2.18.1 恢复到以前的版本,直到它被修复!

Appears this has already been identified as an issue for Moment JS version 2.19. If you have upgraded to 2.19 run npm install moment@2.18.1 to revert back to previous version until it is fixed!

见线程: https://github.com/moment/moment/issues/4216

这篇关于使用Moment JS创建-React-App:找不到模块“./ locale”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆