2

I try to complete this tutorial, but I have some trouble with configure webpack i think. I was making tutorial step by step but it doesn't work..

ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.10.3:webpack (webpack build) on project shop: Failed to run task: 'webpack.js ' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2

error looks like:

[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-35 

webpack.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"] } }] } ] } }; 

app.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 Answer 1

2

It seems that you need to copy-paste the package.json snippet from provided tutorial and run npm i

Sign up to request clarification or add additional context in comments.

1 Comment

You was right. I've added "devDependencies" and forgot about "dependencies". I also had to add client.js file and api dir with two files in it. Now it works. Thank you for your help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.