简体   繁体   English

使用 create-react-app 从 github 导入 JSX 文件时找不到模块

[英]Module not found when importing JSX file off github using create-react-app

I'm struggling with a "module not found" error off a relative import.我正在努力解决相对导入的“找不到模块”错误。 I'm trying to implement this github project: https://github.com/cvdlab/react-planner我正在尝试实现这个 github 项目: https://github.com/cvdlab/react-planner

I've created a new create-react-app project and npm installed the project (react-planner).我创建了一个新的 create-react-app 项目,并且 npm 安装了该项目(react-planner)。 The readme file calls for downloading the "demo catalog" which contains the following file structure:自述文件要求下载包含以下文件结构的“演示目录”:

 > catalog > areas > holes > items > lines > utils > mycatalog.js

mycatalog.js contains the following: mycatalog.js 包含以下内容:

 import * as Areas from "./areas/**/planner-element.jsx"; import * as Lines from "./lines/**/planner-element.jsx"; import * as Holes from "./holes/**/planner-element.jsx"; import * as Items from "./items/**/planner-element.jsx";

Upon running (npm start), I get module not found error on each of these imports.运行(npm start)时,我在每个导入中都收到模块未找到错误。

 ./src/catalog/mycatalog.js Module not found: Can't resolve './areas/**/planner-element.jsx' in 'C:\Users\sgola\Desktop\apps\planner\src\catalog'

These files are definitely located in their respective folders.这些文件肯定位于它们各自的文件夹中。 Catalog folder along with js files are all located in src folder.目录文件夹以及 js 文件都位于 src 文件夹中。 Public contains only index.html and is located outside of src. public 仅包含 index.html 并且位于 src 之外。 I've researched different possible issues from webpack/babel not compiling.jsx files to ** not being recognized as proper path syntax.我研究了从 webpack/babel 不编译.jsx 文件到 ** 不被识别为正确路径语法的不同可能问题。 Nothing is working.没有任何工作。 I'm at a loss, any help would be greatly appreciated.我很茫然,任何帮助将不胜感激。

You have to add import globals plugin to Your project.您必须将导入全局插件添加到您的项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 create-react-app 和 TypeScript 错误:使用 JSX 时“React”必须在范围内 - create-react-app and TypeScript error: 'React' must be in scope when using JSX 使用create-react-app时如何在没有webpack依赖的情况下导入节点模块或JavaScript文件? - How to import node module or JavaScript file without webpack dependency when using create-react-app? create-react-app 中的 JSX 文件 - JSX files in create-react-app 使用 create-react-app 时 .babelrc 文件的位置是什么? - What is the location of .babelrc file when using create-react-app? 在 create-react-app 中导入 png 文件不显示图像 - importing png file in create-react-app is not showing image 使用 create-react-app 时 Github API 返回 CORS 错误 - Github API returns CORS error when using create-react-app 在使用 create-react-app 创建的 reactjs 应用程序中导入 node_module dist js 文件 - Import a node_module dist js file in reactjs application created using create-react-app 带有 create-react-app 的多模块项目 - Multi module projects with create-react-app 使用create-react-app时如何获取电子文件的打字稿 - How to get typescript for electron.js file when using create-react-app 使用 create-react-app base 时,只支持 Electron webview 预加载 file:// 协议 - Electron webview preload only file:// protocol is supported when using create-react-app base
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM