找不到输入模块:错误:无法解析'./src/index.js' [英] Entry module not found: Error: Can't resolve './src/index.js'

查看:1964
本文介绍了找不到输入模块:错误:无法解析'./src/index.js'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在安装一个react启动应用并添加了Webpack,但它说无法解析'./src/index.js'

I was installing a react startup app and added Webpack, but it says Can't resolve './src/index.js'.

浏览器显示

我的文件路径和Package.json内容

Webpack .config.js 目录

 var debug = process.env.NODE_ENV !== "production";
    var webpack = require('webpack');
    var path = require('path');

    module.exports = {
        context: path.join(__dirname, "public"),
    devtool: debug ? "inline-sourcemap" : false,
    entry: "./src/index.js",
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2016', 'stage-0'],
                    plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
                }
            }
        ]
    },
    output: {
        path: __dirname + "/public/",
        filename: "build.js"
    },
    plugins: debug ? [] : [
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurrenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
    ],
};


推荐答案

您的基本网址是路径.join(__ dirname,public),您的条目是 ./ src / index.js 。 Webpack试图在 public dir中找到 ./ src / index.js ;显然它不存在。您应该将条目修改为 ../ src / index.js

Your base URL is path.join(__dirname, "public"), and your entry is ./src/index.js. Webpack tries to find ./src/index.js in public dir; obviously it does not exist. You should modify entry to ../src/index.js.

这篇关于找不到输入模块:错误:无法解析'./src/index.js'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆