Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 控制台从现有目录中抛出该模块:`modulenotfound:Error:Can';t解析'/components/InfoPanel.js/';在`_Javascript_Reactjs_Webpack_Mdbreact - Fatal编程技术网

Javascript 控制台从现有目录中抛出该模块:`modulenotfound:Error:Can';t解析'/components/InfoPanel.js/';在`

Javascript 控制台从现有目录中抛出该模块:`modulenotfound:Error:Can';t解析'/components/InfoPanel.js/';在`,javascript,reactjs,webpack,mdbreact,Javascript,Reactjs,Webpack,Mdbreact,我的react项目抛出这个客户端:159./src/index.js 未找到模块:错误:添加新模块后,无法解析控制台中“D:\ReactProject\src”中的“./components/InfoPanel.js/” 我的董事如下: /ReactProject -dist --src -node_modules -src -components App.js InfoPanel.js

我的react项目抛出这个客户端:159./src/index.js 未找到模块:错误:添加新模块后,无法解析控制台中“D:\ReactProject\src”中的“./components/InfoPanel.js/” 我的董事如下:

    /ReactProject
    -dist
    --src
    -node_modules
    -src
       -components
          App.js
          InfoPanel.js
       -styles
       -images
       index.html
       index.js
    package-lock.json 
    package.json 
    webpack.config.js
    .babelrc
InfoPanel.js的代码:

    import React from 'react';
    import 'react-day-picker/lib/style.css';
    import { MDBCard, MDBCardBody, MDBCardTitle, MDBCardText, MDBCardHeader, MDBBtn, MDBContainer } from "mdbreact";
    import MomentLocaleUtils, { mdbreact, formatDate, parseDate,} from 'react-day-picker/moment';
    import 'moment/locale/it';
    import '../styles/App.css';

    const PanelPage = props => {
        return (
        <MDBContainer>
          <MDBCard style={{ width: "22rem", marginTop: "1rem" }}>
            <MDBCardHeader color="deep-orange lighten-1">Featured</MDBCardHeader>
            <MDBCardBody>
              <MDBCardTitle>Special title treatment</MDBCardTitle>
              <MDBCardText>
                With supporting text below as a natural lead-in to additional
                content.
              </MDBCardText>
              <MDBBtn color="deep-orange">go somewhere</MDBBtn>
            </MDBCardBody>
          </MDBCard>
        </MDBContainer>
        );
        };

    export default PanelPage;   

还有webpack.config信息:

    const path = require("path");
    const HtmlWebpackPlugin = require("html-webpack-plugin");

    module.exports = {
      entry: "./src/index.js",
      output: {
        path: path.join(__dirname, "/dist"),
        filename: "index-bundle.js"
      },
      module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: ["babel-loader"]
          },
          {
            test: /\.css$/,
            use: ["style-loader", "css-loader"]
          }
        ]
      },
      plugins: [
        new HtmlWebpackPlugin({
          template: "./src/index.html"
        })
      ]
    };

怎么了?我没问题。。依赖项看起来没有问题。

问题在于
InfoPanel.js
是一个文件,但导入时会添加
/
添加文件的结尾。因此,
InfoPanel.js
将被视为一个文件夹,您正在导入
InfoPanel.js/index.js
文件

import PanelPage from "./components/InfoPanel.js/";
这一定是

import PanelPage from "./components/InfoPanel.js";
import PanelPage from "./components/InfoPanel.js/";
import PanelPage from "./components/InfoPanel.js";