简体   繁体   English

奇怪的“找不到模块:无法解决”错误

[英]Weird 'Module not found: Can't resolve' error

I know this is common issue that is generally solvable by checking the imports thoroughly, but for some reason, I just can't see what is wrong with mine: 我知道这是一个普遍的问题,通常可以通过彻底检查进口来解决,但是由于某些原因,我只是看不到我的问题所在:

The full error reads: 完整错误为:

./src/components/BookShelf.js
Module not found: Can't resolve './components/Book' in '/Users/../src/components'

Yet my BookShelf.js file's imports are as follows: 但是我的BookShelf.js文件的导入如下:

import React from 'react'
import PropTypes from 'prop-types'
import Book from './components/Book'

Any ideas as to why this is happening would be greatly appreciated! 任何关于为什么发生这种情况的想法将不胜感激! Thanks in advance! 提前致谢!

好像您的BookBookShelf组件位于components文件夹中,因此您的导入应从import Book from './Book'

Read the error more carefully. 仔细阅读错误。

You're importing from /Users/.../src/components . 您是从/Users/.../src/components导入的。 There is no ./components subdirectory of that (since you're already in that directory). 该目录没有./components子目录(因为您已经在该目录中)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM