每当我取消注释 HeadlessUI 组件时,我的屏幕就会变为空白。
我收到以下错误:
'无法在'节点'上执行'removeChild':要删除的节点不是该节点的子节点。
经过一天的研究,我通过各种论坛得出结论,这是一个与 ESM 相关的问题,但没有得到任何工作。
我该如何解决这个问题(如果我可以的话)?
webpack.config.js
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
module.exports = {
output: {
filename: "index.bundle.js",
path: path.join(__dirname, "dist"),
},
module: {
rules: [
{
test: /\.(js|jsx|esm)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.css$/,
exclude: /node_modules/,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
}),
],
};
包.json
{
"name": "sesame-webpack",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "webpack-dev-server --mode development",
"dev": "nodemon server.js",
"build": "webpack --mode production"
},
"dependencies": {
"@headlessui/react": "^1.5.0",
"@heroicons/react": "^1.0.5",
"axios": "^0.26.0",
"bcrypt": "^5.0.1",
"cookie-parser": "^1.4.6",
"express": "^4.17.3",
"multer": "^1.4.4",
"pg": "^8.7.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^6.2.1",
"react-router-dom": "^6.2.1"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"autoprefixer": "^10.4.2",
"babel-loader": "^8.2.3",
"css-loader": "^6.6.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.5.3",
"nodemon": "^2.0.15",
"postcss": "^8.4.7",
"postcss-loader": "^6.2.1",
"style-loader": "^3.3.1",
"tailwindcss": "^3.0.23",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.7.4"
}
}
.babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}