找不到 React Babel 核心模块

React Babel Core Module Not Found

我是通过观看一些视频教程来学习 React.js 的。它工作正常,但今天我继续工作并将状态添加到我的组件,保存后突然出现 babel-core 错误。
我刚接触React,所以我不明白这是什么错误,我认为这与我今天制作的组件的变化无关。
到目前为止,我还上传了我的项目 github here

在网页上我收到此错误消息 -

Failed to compile

./node_modules/babel-core/lib/helpers/resolve.js
Module not found: Can't resolve 'module' in 'C:\Users\Sachin Verma\Desktop\WebD work\React\The Burger Builder\node_modules\babel-core\lib\helpers'

在控制台中我得到这个长错误 -

Uncaught Error: Cannot find module "module"
    at webpackMissingModule (resolve.js:34)
    at Object.<anonymous> (resolve.js:34)
    at Object../node_modules/babel-core/lib/helpers/resolve.js (resolve.js:46)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../node_modules/babel-core/lib/helpers/resolve-from-possible-names.js (resolve-from-possible-names.js:6)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object.<anonymous> (resolve-plugin.js:6)
    at Object../node_modules/babel-core/lib/helpers/resolve-plugin.js (resolve-plugin.js:21)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object.<anonymous> (option-manager.js:43)
    at Object../node_modules/babel-core/lib/transformation/file/options/option-manager.js (option-manager.js:383)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object.<anonymous> (index.js:42)
    at Object../node_modules/babel-core/lib/transformation/file/index.js (index.js:737)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../node_modules/babel-core/lib/api/node.js (node.js:6)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../node_modules/babel-core/index.js (index.js:1)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../src/components/Burger/Burger.js (Burger.css:26)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../src/containers/BurgerBuilder/BurgerBuilder.js (Layout.js:15)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../src/App.js (fetch.js:461)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object../src/index.js (index.css?f255:26)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at fn (bootstrap 8d64744152fbd1b327ed:88)
    at Object.0 (registerServiceWorker.js:117)
    at __webpack_require__ (bootstrap 8d64744152fbd1b327ed:678)
    at bootstrap 8d64744152fbd1b327ed:724
    at bootstrap 8d64744152fbd1b327ed:724
index.js:2178 ./node_modules/babel-core/lib/helpers/resolve.js
Module not found: Can't resolve 'module' in 'C:\Users\Sachin Verma\Desktop\WebD work\React\The Burger Builder\node_modules\babel-core\lib\helpers'

更新: 我 运行 npm run eject 添加一些配置,以便组件 css 文件中的 class 名称不会相互冲突。
我添加了这两行。

该特定错误是由您未安装的 babel-core 库中的 you having inadvertently added this import 引起的:

import { transform } from 'babel-core';

删除线,您就可以开始了。

但是,我仍然想知道为什么你在你的 repo 中做了 react-scripts eject...

我猜你已经在 Udemy 上学习了 React 的 Maximilian class 并且你在第 8 节 - 第 129 课中遇到了这个问题。这是因为当你尝试创建变量 transformedIngredient 时你可能得到了一个建议transform 关键字,它是 babel-core 中的保留关键字,已导入到您的 js 文件顶部。删除它,你就可以开始了。