为了账号安全,请及时绑定邮箱和手机立即绑定

如何正确配置webpack?

如何正确配置webpack?

慕森王 2023-08-10 15:42:09
我认为配置 webpack 时遇到了一些问题。我正在一步步制作教程,但它不起作用。错误] 无法在项目商店上执行目标 com.github.eirslett:frontend-maven-plugin:1.10.3:webpack (webpack build):无法运行任务:&ldquo;webpack.js&rdquo;失败。org.apache.commons.exec.ExecuteException:进程退出并出现错误:2错误看起来像:[INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve './client' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]  @ ./src/main/js/app.js 29:13-32[INFO] [INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve 'react' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]  @ ./src/main/js/app.js 25:12-28[INFO] [INFO] ERROR in ./src/main/js/app.js[INFO] Module not found: Error: Can't resolve 'react-dom' in '/home/kk/IdeaProjects/e-commerce/src/main/js'[INFO]  @ ./src/main/js/app.js 27:15-35webpack.config.js:var path = require('path');module.exports = {    entry: './src/main/js/app.js',    devtool: 'sourcemaps',    cache: true,    mode: 'development',    output: {        path: __dirname,        filename: './src/main/resources/static/built/bundle.js'    },    module: {        rules: [            {                test: path.join(__dirname, '.'),                exclude: /(node_modules)/,                use: [{                    loader: 'babel-loader',                    options: {                        presets: ["@babel/preset-env", "@babel/preset-react"]                    }                }]            }        ]    }};应用程序.js:'use strict';const React = require('react');const ReactDOM = require('react-dom');const client = require('./client');class App extends React.Component {...}class EmployeeList extends React.Component{...}class Employee extends React.Component{...}ReactDOM.render(<App/>, document.getElementById('react'))
查看完整描述

1 回答

?
当年话下

TA贡献1890条经验 获得超9个赞

看来您需要从提供的教程中复制粘贴package.json片段并运行npm i



查看完整回答
反对 回复 2023-08-10
  • 1 回答
  • 0 关注
  • 59 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信