[英]React: Cannot Find module './WebpackMissingModule'
I'm currently giving my first steps on React and I'm having some issues when trying to export components.我目前正在尝试使用 React 的第一步,但在尝试导出组件时遇到了一些问题。
My current index.js file is as following:我当前的 index.js 文件如下:
import React from 'react';
import ReactDOM from 'react-dom';
import SearchBar from './components/search_bar';
const API_KEY = '...';
//Create a new component. It should output some html
const App = function(){
return <div>
<SearchBar />
</div>;
}
ReactDOM.render(<App />, document.querySelector('.container'));
And my search_bar.js file:还有我的 search_bar.js 文件:
import React from 'react';
const SearchBar = function(){
return <input />;
};
export default SearchBar;
My current file structure may be seen in the following image:我当前的文件结构如下图所示:
The problem is that I'm not being able to import the SearchBar element.问题是我无法导入 SearchBar 元素。 I'm having the error that can be seen on the image:
我有可以在图像上看到的错误:
Cannot Find module './WebpackMissingModule'
Any idea on what may be causing this issue?关于可能导致此问题的任何想法?
我也对此感到困惑,但刷新浏览器对我来说是固定的。
Seems the question has been asked before see if this solution helps: 在看此解决方案是否有帮助之前,似乎已经问过这个问题:
Webpack Missing Module 'Module Not Found' Webpack缺少模块“找不到模块”
https://github.com/proj4js/proj4js/issues/214 https://github.com/proj4js/proj4js/issues/214
npm install --save-dev npm-install-webpack-plugin npm install --save-dev npm-install-webpack-plugin
Usually I perform npm install name_of_module --save 通常我执行npm install name_of_module --save
goodluck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.