代码之家  ›  专栏  ›  技术社区  ›  Ryuujo dhara gosai

ReactJS:无法解析“@babel/runtime/helpers/builtin/interopRequireDefault”

  •  0
  • Ryuujo dhara gosai  · 技术社区  · 6 年前

    未能编译 ./node_modules/@material-ui/icons/Menu.js Module not found: Can't resolve '@babel/runtime/helpers/builtin/interopRequireDefault' inb'C:\LocalServer\static-page\node_modules\@material-ui\icons' 此错误发生在生成时,无法排除。

    import React, {Component} from 'react';
    import AppBar from '@material-ui/core/AppBar';
    import ToolBar from '@material-ui/core/Toolbar';
    import MenuIcon from '@material-ui/icons/Menu';
    import IconButton from '@material-ui/core/IconButton';
    
    class Header extends Component{
      render(){
        return(
          <div>
            <AppBar position="fixed" style={{backgroundColor:'#2f2f2f',boxShadow:'none',padding:'10px 0px'}}>
              <ToolBar>
                <div className="header_logo">
                  <div className="font_righteous header_logo_venue">The Venue</div>
                  <div className="header_logo_title">MUSICAL EVENTS</div>
                </div>
                <IconButton aria-label="Menu" color="inherit" onClick={()=>console.log('open')}>
                  <MenuIcon/>
                </IconButton>
              </ToolBar>
            </AppBar>
          </div>
        );
      }
    }
    
    export default Header
    

    教程中说我应该从中重命名目录 @material-ui/core/Menu 在线4至 @material-ui/icons/Menu @物料界面/核心/菜单 ,代码正在运行,按钮工作,但没有出现图标。

    但是,从教程中可以看出,该程序正在运行,并显示了图标。

    It has a white hamburger button icon on the header

    enter image description here 这是我尝试更改时的错误代码 core/Menu icons/Menu

    This is the result when I changed to core/Menu 核心/菜单

    编辑:我现在拥有的package.json:

    {   "name": "static-page",   "version": "0.1.0",   "private": true,   "dependencies": {
        "@babel/runtime": "7.0.0-beta.55",
        "@material-ui/core": "^1.4.3",
        "@material-ui/icons": "^1.1.0",
        "react": "^16.7.0",
        "react-dom": "^16.7.0",
        "react-reveal": "^1.2.2",
        "react-scripts": "2.1.3",
        "react-scroll": "^1.7.9",
        "react-slick": "^0.23.1"   },   "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"   },   "eslintConfig": {
        "extends": "react-app"   },   "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"   ] }
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   maazadeeb    6 年前

    找到梅 issue 这说明了完全相同的问题。这个 solution @material-ui/icons@1.1.1 .

    @material-ui/icons@^1.1.0 作为依赖项,删除 node_modules 跑步 npm install

        2
  •  0
  •   Seyed Kazem Mousavi    4 年前

    试一试:

    @babel/runtime:“7.0.0-beta.55”