[英]React couldn't find the module
I have structured everything properly. 我已经正确地构造了一切。 But while compiling react keep on says module not found how to fix?
但是在编译时继续说模块没找到怎么解决?
Module not found: Can't resolve 'ui-config/themes' in 'C:\\Users\\Goodwork\\desktop\\mihy-ui-framework\\src' 找不到模块:无法解析“ C:\\ Users \\ Goodwork \\ desktop \\ mihy-ui-framework \\ src”中的“ ui-config / themes”
this is my index file 这是我的索引文件
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from "react-router-dom";
import { MuiThemeProvider, createMuiTheme } from '@material-
ui/core/styles';
import { Provider } from 'react-redux';
import store from 'ui-redux/store';
import './index.css';
import App from 'ui-views/App';
import registerServiceWorker from './registerServiceWorker';
import themeObject from "ui-config/themes";
Unless you have configured webpack with resolve
alias ui-config
, it's not going to work because webpack looks for npm module called ui-config
in node_modules
. 除非你已经配置了的WebPack
resolve
别名ui-config
,它不会工作,因为的WebPack查找名为NPM模块ui-config
在node_modules
。
To fix it, Add to your webpack configuration the following: 要解决此问题,请在Webpack配置中添加以下内容:
resolve: {
alias: {
'ui-config: 'relative-path-to-ui-config'
}
}
alternatively, you can adjust the relative path in your import 或者,您可以调整导入中的相对路径
import themeObject from "./ui-config/themes";
This is less optimal because eventually you'll end up struggeling with nested folders import '../../../../../' to find ui-config relative path. 这不是最佳选择,因为最终您将陷入嵌套文件夹导入'../../../../../'的困境,以查找ui-config相对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.