找不到模块:无法解析

蒂米

我正在使用React.js开发组件,并且控制台抛出以下错误

编译失败:

./src/components/file_tree.js
   Module not found: Can't resolve '.src/components/directory.js' in 
'D:\Treebeard\src'

在这里,您可以看到file_tree.js中的代码

import React from 'react';
import ReactDOM from 'react';
import { Directory } from './components/directory.js';

directory.js中的代码

import React from 'react';
import { TriangleDown } from './components/file_tree.js';
import { FolderIcon } from './components/file_tree.js';
import { formatName } from './components/file_tree.js';
import { renderTree } from './components/file_tree.js';

在这里,App.js代码以防万一:

import React from 'react';
import ReactDOM from 'react-dom';
import { SearchEngine } from './components/search_engine.js';
import { FileTree } from './components/file_tree.js';
import { Directory } from './components/directory.js';

我检查了两个文件的文件路径,一切似乎都还不错,但是抛出了此错误。我是否缺少有关文件路径的信息?无论directory.jsfile_tree.js都在里面” ./src/components'文件夹中。

App.js位于“ ./src”文件夹中。

博杰德拉·拉尼雅(Bhojendra Rauniyar)

由于您正在从同一目录访问文件路径。它应该是:

file_tree.js:

import React from 'react';
import ReactDOM from 'react';
import { Directory } from './directory.js';

directory.js:

import React from 'react';
import { TriangleDown } from './file_tree.js';
import { FolderIcon } from './file_tree.js';
import { formatName } from './file_tree.js';
import { renderTree } from './file_tree.js';

App.js:没关系。由于您正在从当前目录访问组件文件路径。

import React from 'react';
import ReactDOM from 'react-dom';
import { SearchEngine } from './components/search_engine.js';
import { FileTree } from './components/file_tree.js';
import { Directory } from './components/directory.js';

如需进一步的帮助,请参阅这篇文章,它将在相关情况下为您提供帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

找不到模块:错误:无法解析模块

找不到模块:错误:无法解析模块

找不到模块:错误:无法解析“ hammerjs”

找不到模块:错误:无法解析“ ./templates”

找不到模块:无法解析“./AppRoutes”

找不到模块:错误:无法解析“ fs”

找不到模块:错误:无法解析“ReactDOM”

找不到打字稿模块无法解析

找不到模块:无法解析“../file”

找不到模块:无法解析'./registerServiceWorker

找不到模块:无法解析“ readline”

找不到模块:错误:无法解析“ dropzone”

找不到REACTJS模块:无法解析“ axios”

找不到模块:无法解析 './src/refreshableScrollView

找不到模块:无法解析“../components”

找不到模块:错误:无法解析模块“服务器”

找不到Webpack模块:错误:无法解析模块

“找不到模块:错误:无法解析模块'react / lib / ReactMount'”

找不到模块:错误:无法解析模块'***。jpg'

找不到模块:错误:无法解析模块“ fs”

MUI:找不到模块“找不到模块:错误:无法解析'时刻'”

找不到模块:无法解析“ @ material-ui / core / Container”

找不到模块:无法解析'@ material-ui / core / AppBar'

找不到模块:无法解析'react / lib / React'

找不到模块:无法解析“ material-ui / styles / colors”

错误:找不到模块:错误:无法解析“ @ angular / cdk / scrolling”

Angular 8 - 找不到模块:错误:无法解析“fs”

反应:找不到模块:无法解析“ react-html-parser”

找不到模块:无法解析“react-redux-form”