找不到入口模块

时间:2019-01-08 20:53:50

标签: babel-loader babel-jest babel-polyfill webpack.config.js

  

错误,错误:子编译失败:
    找不到输入模块:错误:无法解析“ / Users / MarkPierre / Desktop / es6-project-2019”中的“ /Users/MarkPierre/Desktop/es6-project-2019/src/index.html”:
    错误:无法解析“ / Users / MarkPierre / Desktop / es6-project-2019”中的“ /Users/MarkPierre/Desktop/es6-project-2019/src/index.html”

当我运行命令npm run start时,出现上述错误消息。 我已经检查了路径,就在那里。有什么想法吗?

似乎template: './starter/src/index.html'出现了问题。我删除了starter,但仍然是同一问题。非常令人沮丧,因为这是配置的最后部分:-(

babelrc文件

{
    "presets": [
        ["@babel/preset-env", {
            "targets": {
                "browsers": [
                    "last 5 versions",
                    "ie >= 8"
                ]
            }
        }]
    ]
} 

package.json

{
    "name": "forkify",
    "version": "1.0.0",
    "description": "forkify project",
    "main": "index.js",
    "scripts": {
        "dev": "webpack: --mode development",
        "build": "webpack --mode production",
        "start": "webpack-dev-server --mode development --open"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@babel/core": "^7.2.2",
        "@babel/preset-env": "^7.2.3",
        "babel-loader": "^8.0.5",
        "html-webpack-plugin": "^3.2.0",
        "webpack-dev-server": "^3.1.14"
    },
    "dependencies": {
        "@babel/polyfill": "^7.2.5"
    }
}

webpack

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

module.exports = {
    entry: ['@babel/polyfill', './starter/src/js/index.js'],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'js/bundle.js',
    },
    devServer: {
        contentBase: './dist'
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: './src/index.html'
        })
    ],
    module: {
        rules: [{
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
                loader: 'babel-loader'
            }
        }]
    }

};

0 个答案:

没有答案