请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

error in entry module not found

老师,在生成bundle.js过程中,控制台输入webpack,但是却显示ERROR in Entry module not found: Error: Can't resolve './js/index.js' in 'D:\mukewangzuoye\react_ex\05-01/src'错误,这是怎么回事呢?

正在回答 回答被采纳积分+3

2回答

qq_小江南_04298178 2018-03-01 18:04:12

同学你好,我也遇到了这个问题,请问你是如何解决的ERROR in Entry module not found: Error: Can't resolve './src/js/index.js' in 'D:\reactD\mk\05-01-4/src'

0 回复 有任何疑惑可以回复我~
Parry 2017-12-06 08:09:23

index.js 中的代码是?路径对吗?

0 回复 有任何疑惑可以回复我~
  • index.js中的代码:
    var React = require('react');
    var ReactDOM = require('react-dom');
    
    ReactDOM.render(
      <h1>Hello world</h1>,
      document.getElementById('example')
    );
    
    webpack.config.js内容:
    var webpack = require('webpack');
    var path = require('path');
    
    module.exports = {
        context: __dirname+'/src',
        entry: "./src/js/index.js",
        module: {
            loaders: [
                {
                    test: /\.js?$/,
                    exclude: /(node_modules)/,
                    loader: 'babel-loader',
                    query: {
                        presets: ['react', 'es2015']
                    }
                }
            ]
        },
        output: {
            path: __dirname+"/src/",
            filename: "bundle.js"
        }
    };
    
    感觉没有问题啊!!
    
    我对比从慕课上下载的代码发现那里面的代码和课程里面讲解的代码不一样-webpack.config.js,我是按照视频讲解的那样写的
    回复 有任何疑惑可以回复我~ 2018-03-02 09:23:46
  • 同学你好,下载我的源码可以运行吗?
    回复 有任何疑惑可以回复我~ 2018-03-02 10:25:34
  • 不可以,有报错,我的操作步骤如下:
    (1)D:\reactD\mk\IMOOC-React-master\05-02>cnpm install
    (2)D:\reactD\mk\IMOOC-React-master\05-02>webpack
    Hash: 0883de5a5a2153383c68
    Version: webpack 1.15.0
    Time: 31ms
    
    ERROR in Entry module not found: Error: Cannot resolve module 'babel-loader' in D:\reactD\mk\IMOOC-React-master\05-02
    (3)D:\reactD\mk\IMOOC-React-master\05-02>cnpm install --save babel-loader
    √ Installed 1 packages
    √ Linked 0 latest versions
    √ Run 0 scripts
    √ All packages installed (used 719ms, speed 52.43kB/s, json 1(37.7kB), tarball 0B)
    (4)D:\reactD\mk\IMOOC-React-master\05-02>webpack
    Hash: 0883de5a5a2153383c68
    Version: webpack 1.15.0
    Time: 617ms
        + 1 hidden modules
    
    ERROR in ./src/js/index.js
    Module build failed: TypeError: fileSystem.statSync is not a function
        at module.exports (D:\reactD\mk\IMOOC-React-master\05-02\node_modules\_babel-loader@7.1.3@babel-loader\lib\utils\exists.js:7:25)
        at find (D:\reactD\mk\IMOOC-React-master\05-02\node_modules\_babel-loader@7.1.3@babel-loader\lib\resolve-rc.js:13:9)
        at Object.module.exports (D:\reactD\mk\IMOOC-React-master\05-02\node_modules\_babel-loader@7.1.3@babel-loader\lib\index.js:113:132)
    回复 有任何疑惑可以回复我~ 2018-03-02 15:55:41
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信