Webpack已安装到React中。但是,当我尝试创建一个dist文件时,出现了错误。如何修复?
![enter image description here](https://istack.dev59.com/78CN7.webp)
从package.json文件中:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"builder": "webpack"
},
Webpack.config.js:
const path = require('path');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
};
index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />,
document.getElementById('root')
);