V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Keanuo
V2EX  ›  前端开发

antd 在 create-react-app 下无法使用?

  •  
  •   Keanuo ·
    KeanuoLeung · 2020-05-01 20:19:10 +08:00 · 2485 次点击
    这是一个创建于 1449 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一个初始化的 create-react-app 框架,在 App.js 中引入了 antd,除此之外其他什么都没干,编译之后就报错。大家有遇到这种情况的吗?


    Compiled with warnings.

    ./node_modules/moment/src/lib/locale/locales.js Critical dependency: the request of a dependency is an expression

    第 1 条附言  ·  2020-05-01 22:13:15 +08:00
    找到原因了
    https://github.com/moment/moment/issues/5484
    https://github.com/moment/moment/issues/5489
    解决方案:
    去 package-lock.json 里把 moment 的版本锁定在 2.24.0
    "moment": {
    "version": "2.24.0",
    "resolved": "https://registry.npm.taobao.org/moment/download/moment-2.24.0.tgz",
    "integrity": "sha1-DQVdU/UFKqZTyfbraLtdEr9cK1s="
    },
    5 条回复    2020-05-02 17:24:29 +08:00
    GDC
        1
    GDC  
       2020-05-01 20:49:49 +08:00 via iPhone
    一直在 cra 里用 antd 没遇过你说的情况
    worldtongfb
        2
    worldtongfb  
       2020-05-01 21:54:59 +08:00
    我也卡这里了,应该是某个组件引入 moment 然后配置不对把
    Keanuo
        3
    Keanuo  
    OP
       2020-05-01 22:10:56 +08:00   ❤️ 1
    @worldtongfb 对,去 package-lock.json 里把 moment.js 的版本锁在 2.24.0 就好了
    worldtongfb
        4
    worldtongfb  
       2020-05-01 22:26:28 +08:00
    @Keanuo #3 嗯 可以了 谢谢
    rokeyzki
        5
    rokeyzki  
       2020-05-02 17:24:29 +08:00
    @GDC 因为这是 antd 最新版本的问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2710 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 15:06 · PVG 23:06 · LAX 08:06 · JFK 11:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.