标签: react-refresh

由于(不存在)导入react-refresh而导致编译错误

我们目前正在开发一个小型应用程序,它只渲染外部 React 组件(因为它是外部npm install组件)。此应用程序的目的是获取一些 JSON 配置并将其作为 prop 传递给该组件以演示其用法。

该应用程序是由 create-react-app 创建的,它对脚手架应用程序的唯一更改是 index.tsx 和 App.tsx 文件的内容。嗯,公共目录中还添加了两个 JSON 文件。

问题:编译失败。

现在的问题是,这个项目可以在我同事的机器上编译并运行,但不能在我的机器上运行。之后npm cinpm start得到以下信息:

Failed to compile.

Module not found: Error: You attempted to import /home/newlukai/story/app/node_modules/react-refresh/runtime.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
assets by path static/js/*.js 4.81 MiB
  asset static/js/bundle.js 4.8 …
Run Code Online (Sandbox Code Playgroud)

reactjs create-react-app react-refresh

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

create-react-app ×1

react-refresh ×1

reactjs ×1