在浏览器中,我收到错误
Failed to compile Module not found: Can't resolve '@material-ui/core/Container'
它正在寻找我的组件目录中的组件而不是node_modules。我无法将目录更改为node_modules ../../,因为node_modules位于src目录之外,并且Create React App不允许我这样做。
我使用 yarn 来删除和$ yarn 添加@material-ui/core。我尝试过yarn run build,这给了我错误
Cannot find module: '@material-ui/core/Container'. Make sure this package is installed. You can install this package by running: yarn add @material-ui/core/Container.
当我尝试添加它时,出现错误
error Couldn't find package "@material-ui/core/Container" on the "npm" registry.
这是我拥有的相关依赖项:
"@material-ui/core": "^3.9.3",
"@material-ui/icons": "^3.0.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
我希望看到页面的内容不会占据屏幕的整个宽度,但相反,我收到了编译失败错误。
请您参考如下方法:
Container不属于 material-ui package.json 中指定的版本.
要升级,请运行以下命令:
$ yarn add @material-ui/core@next
您可能必须删除旧的稳定版本(如果您可以选择的话)。
React 和 React-dom >= 16.8.0 都是对等依赖项所需要的,因此 material-ui 的实验性升级应该是您需要使用的全部 Container .






