gpt4 book ai didi

javascript - 无法加载配置 "react"以从

转载 作者:行者123 更新时间:2023-12-03 13:56:20 26 4
gpt4 key购买 nike

我正在尝试使用以下网站在不使用 create-react-app 的情况下创建一个 react 应用程序:
https://www.freecodecamp.org/news/how-to-set-up-deploy-your-react-app-from-scratch-using-webpack-and-babel-a669891033d4/
但是,我不断收到这个错误,上面写着
./src/index.js 中的警告
模块警告(来自 ./node_modules/eslint-loader/dist/cjs.js):
无法加载配置“react”以扩展。
我已经尝试安装所有依赖项并花了几个小时在谷歌上搜索答案,但我似乎无法找出问题所在。
这是我的 package.json:

{
"name": "xxx",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --mode development",
"format": "prettier --write \"src/**/*.js\"",
"eslint-fix": "eslint --fix \"src/**/*.js\"",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.10.4",
"react": "^16.13.1",
"react-bootstrap": "^1.3.0",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"css-loader": "^4.3.0",
"eslint": "^7.9.0",
"eslint-config-react": "^1.1.7",
"eslint-loader": "^4.0.2",
"eslint-plugin-react": "^7.20.6",
"html-webpack-plugin": "^4.4.1",
"less": "^3.12.2",
"less-loader": "^7.0.1",
"prettier": "2.1.1",
"style-loader": "^1.2.1",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
}
}
这是我的 webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
// path: __dirname + '/dist',
path: path.resolve(__dirname, 'build'),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
contentBase: './build'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader', 'eslint-loader']
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader',
],
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve('./index.html'),
})],
};
这是我的 .eslintrc:
  {
"parser": "babel-eslint",
"extends": "react",
"env": {
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
}
}
这是我的.babelrc:
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
有没有人有什么建议?我正在绞尽脑汁想弄清楚这一点,但我遇到了很多麻烦。它加载网页,但是根本没有使用 react 。
先感谢您!!我真的很感谢你的帮助。

最佳答案

我遇到了与 create-react-app 类似的问题我做到了

yarn add eslint-config-react-app -D
我认为你应该尝试:
yarn add eslint-config-react -D

关于javascript - 无法加载配置 "react"以从,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63912721/

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