V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Keanuo

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

  •  
  •   Keanuo ·
    KeanuoLeung · May 1, 2020 · 3471 views
    This topic created in 2197 days ago, the information mentioned may be changed or developed.

    一个初始化的 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

    Supplement 1  ·  May 1, 2020
    找到原因了
    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 replies    2020-05-02 17:24:29 +08:00
    GDC
        1
    GDC  
       May 1, 2020 via iPhone
    一直在 cra 里用 antd 没遇过你说的情况
    holdmycosmo
        2
    holdmycosmo  
       May 1, 2020
    我也卡这里了,应该是某个组件引入 moment 然后配置不对把
    Keanuo
        3
    Keanuo  
    OP
       May 1, 2020   ❤️ 1
    @worldtongfb 对,去 package-lock.json 里把 moment.js 的版本锁在 2.24.0 就好了
    holdmycosmo
        4
    holdmycosmo  
       May 1, 2020
    @Keanuo #3 嗯 可以了 谢谢
    rokeyzki
        5
    rokeyzki  
       May 2, 2020
    @GDC 因为这是 antd 最新版本的问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   919 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 20:38 · PVG 04:38 · LAX 13:38 · JFK 16:38
    ♥ Do have faith in what you're doing.