create-react-app ``` react-scripts build失败,找不到模块:错误:无法解析'../../helpers/esm/typeof' ```

bkkx9g8r  于 2个月前  发布在  React
关注(0)|答案(4)|浏览(42)

描述bug

在将 react-scripts 升级到最新的 5.0.0(之前是 4.0.1)后,我无法构建我的项目,因为我遇到了这个问题:

Module not found: Error: Can't resolve '../../helpers/esm/typeof' in '/Users/ickata/Work/Galaxy/node_modules/@babel/runtime/helpers/esm'
Did you mean 'typeof.js'?
BREAKING CHANGE: The request '../../helpers/esm/typeof' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

你尝试恢复依赖了吗?

是的,没有成功。

你在用户指南中搜索了哪些术语?

  • "模块未加载"
  • "react-scripts build"

环境

  • MacOS Monterey (12.1)
  • NodeJS v14.17.5
Environment Info:

  current version of create-react-app: 5.0.0
  running from /Users/ickata/.npm/_npx/39396/lib/node_modules/create-react-app

  System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Binaries:
    Node: 14.17.5 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.14 - /usr/local/bin/npm
  Browsers:
    Chrome: 97.0.4692.99
    Edge: 87.0.664.75
    Firefox: 96.0.2
    Safari: 15.2
  npmPackages:
    react: ^17.0.1 => 17.0.1
    react-dom: ^17.0.1 => 17.0.1
    react-scripts: ^5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

重现问题的步骤

没有确切的步骤,但是我无法使用全新的 CRA 安装来重现问题。

ttp71kqs

ttp71kqs1#

基于mui/material-ui#23290,您需要babel-runtime 7.12.0或更高版本才能与webpack 5一起使用。

yzckvree

yzckvree2#

但是我在生成的package.json的依赖列表中没有看到它,即使我创建了一个全新的应用。

uurv41yg

uurv41yg3#

我正在遇到一个类似的错误,与@babel/runtime@7.19.0有关。
编辑:我的解决方法是避免导入。在NexJS应用中,它可以正常工作。

gc0ot86w

gc0ot86w4#

对于那些遇到同样问题的人,这是我的解决方案:mui/material-ui#23290 (评论)

相关问题