gpt4 book ai didi

css - 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”

转载 作者:行者123 更新时间:2023-12-03 13:23:53 24 4
gpt4 key购买 nike

我正在使用yarn为我的react元素设置webpack,并出现此错误:

ERROR in ./src/app.js 67:6 Module parse failed: Unexpected token (67:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders ℹ 「wdm」: Failed to compile.

webpack.config.js

const path = require("path");

module.exports = {
entry: "./src/app.js",
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
},
module:{
rules:[{
loader: 'babel-loader',
test: '/\.(js|jsx)$/',
exclude: /node_modules/
}]
},
devtool: 'cheap-module-eval-source-map',
devServer: {
contentBase: path.join(__dirname, 'public')
}
}
.babelrc
{
"presets": ["env", "react","@babel/preset-env"],
"plugins": [
"transform-class-properties"
]
}

package.json

{
"name": "react",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"serve": "live-server public/",
"build": "webpack",
"dev-server": "webpack-dev-server"
},
"dependencies": {
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"live-server": "^1.2.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"webpack": "^4.39.3",
"webpack-dev-server": "^3.8.0"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"babel-loader": "^8.0.6",
"webpack-cli": "^3.3.8"
}
}

最佳答案

您正在使用不必要的转义字符:这不是必需的。

替换 test: '/\.(js|jsx)$/', 替换为 test:/\.js $|jsx/, 它应该可以正常工作。

我在我的计算机中复制了您的问题,并发现了相同的问题,并通过上述修复解决了问题。

希望这有帮助,编码愉快!

关于css - 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57924348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com