• Can't resolve '@babel/runtime/helpers/esm/extends' 的解决


    同事检出我的项目,在 roadhog build 编译时,出现问题:

    Module not found: Error: Can't resolve '@babel/runtime/helpers/esm/extends' in '/Users/everlose/workspace/scnode/msgcenter-sms/node_modules/history/esm'

    根据下面的 ls 命令,我们能看到 history 目录的确不存在与项目跟路径,'/Users/everlose/workspace/scnode/msgcenter-sms/node_modules/history/esm'。

    $ npm ls history
    msgcenter-sms@1.7.10 /Users/everlose/workspace/scnode/msgcenter-sms
    ├─┬ dva@2.4.1
    │ ├── history@4.6.3  deduped
    │ ├─┬ react-router-dom@4.3.1
    │ │ ├── history@4.9.0 
    │ │ └─┬ react-router@4.3.1
    │ │   └── history@4.9.0 
    │ └─┬ react-router-redux@5.0.0-alpha.9
    │   └── history@4.9.0 
    

    找到 github 上的 history 模块代码,翻到 4.9.0 发现它所依赖 babel 的版本的确变为了 7,而项目主 babel 版本还是6。猜测可能是 babel 主版本的影响。

    查看其 4.7.2 及之前还是使用 babel 6 的。故而解决方法就是

    $ npm install history@4.7.2 --save
    $ rm -rf node_modules
    $ npm install
    
    $ npm ls history
    msgcenter-sms@1.7.10 /Users/everlose/workspace/scnode/msgcenter-sms
    ├─┬ dva@2.4.1
    │ ├── history@4.7.2  deduped
    │ ├─┬ react-router-dom@4.3.1
    │ │ ├── history@4.7.2  deduped
    │ │ └─┬ react-router@4.3.1
    │ │   └── history@4.7.2  deduped
    │ └─┬ react-router-redux@5.0.0-alpha.9
    │   └── history@4.7.2  deduped
    └── history@4.7.2 
    

    再编译时正常

    $ npm run build
    
    > msgcenter-sms@1.7.10 build /Users/everlose/workspace/scnode/msgcenter-sms
    > roadhog build
    
    Build completed in 33.632s
    
    Compiled successfully.
    
    File sizes after gzip:
    
      681.58 KB  public/index.657ff4cf.js
      37.33 KB   public/index.424c8126.css
    
    

    心得

    像这样大的更新,依赖版本整个换了,那个 history 依赖包不应该只是升级中间版本的。这些依赖包简直和无限套娃一样,我都不知道什么时候用到了,真的是坑人。

  • 相关阅读:
    事务的原理 学习笔记
    JAVA并发-从缓存一致性说volatile 讲的很好
    【mysql】mysql有哪些权限
    spring data jpa mysql 悲观锁
    Mysterious Bacteria LightOJ
    Harmonic Number LightOJ
    Aladdin and the Flying Carpet LightOJ
    Pairs Forming LCM LightOJ
    Harmonic Number (II) LightOJ
    Goldbach`s Conjecture LightOJ
  • 原文地址:https://www.cnblogs.com/everlose/p/12505375.html
Copyright © 2020-2023  润新知