ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2020-03-16 17:54:59  阅读:317  来源: 互联网

标签:4.7 resolve babel sms helpers router msgcenter history


同事检出我的项目,在 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 依赖包不应该只是升级中间版本的。这些依赖包简直和无限套娃一样,我都不知道什么时候用到了,真的是坑人。

标签:4.7,resolve,babel,sms,helpers,router,msgcenter,history
来源: https://www.cnblogs.com/everlose/p/12505375.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有