ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` TypeError: Cannot read property 'length' of undefined ``` ``` if (webpackConfigurationValidationErrors.length) { ^ TypeError: Cannot read property 'length' of undefined at processConfiguredOptions (E:\Vue7\react108\node_modules\webpack-cli\bin\convert-argv.js:160:44) at module.exports (E:\Vue7\react108\node_modules\webpack-cli\bin\convert-argv.js:150:10) at Object.<anonymous> (E:\Vue7\react108\node_modules\webpack-dev-server\bin\webpack-dev-server.js:84:40) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! react108@1.0.0 dev3: `webpack-dev-server --hot --mode development` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the react108@1.0.0 dev3 script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2021-10-08T08_31_03_073Z-debug.log ``` ``` npm.cmd install ``` ``` npm.cmd update ``` ``` npm.cmd run dev3 ``` ``` > webpack-dev-server --hot --mode development 10% building 0/1 entries 0/0 dependencies 0/0 modulesi 「wds」: Project is running at http://localhost:8080/ ``` package.json ``` { "name": "react108", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "webpack", "dev1": "webpack --watch", "dev2": "webpack-cli --hot --mode development", "dev3": "webpack-dev-server --hot --mode development" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "babel-core": "^6.26.3", "babel-loader": "^7.1.5", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "eslint": "^7.32.0", "eslint-config-airbnb": "^18.2.1", "eslint-loader": "^4.0.2", "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-react": "^7.26.1", "html-webpack-plugin": "^5.3.2", "webpack": "^5.58.0", "webpack-cli": "^3.3.12", "webpack-dev-server": "^3.11.2" }, "dependencies": { "react": "^17.0.2", "react-dom": "^17.0.2" } } ``` webpack.config.js ``` var path = require('path'); var webpack = require('webpack'); var HtmlwebpackPlugin = require('html-webpack-plugin'); var ROOT_PATH = path.resolve(__dirname); var APP_PATH = path.resolve(ROOT_PATH,'src'); var BUILD_PATH = path.resolve(ROOT_PATH,'build'); module.exports = { entry:{ app:path.resolve(APP_PATH,'index.jsx') }, output:{ path:BUILD_PATH, filename:'bundle.js' }, devtool:'eval-source-map', devServer:{ historyApiFallback:true, hot:true, progress:true }, module:{ // preLoaders:[ // { // test:/\.jsx?$/, // loader:['eslint'], // include:APP_PATH // } // ], rules:[ { test:/\.jsx?$/, loader:'babel-loader', include:APP_PATH } ], // plugins:[ // new HtmlwebpackPlugin({ // title:'my first react app' // }) // ], // resolve:{ // extensions:['','.js','jsx'] // } } } ``` .babelrc ``` { "presets":["es2015","react"] } ``` .eslintrc ``` { "extends":"airbnb", "rules":{ "comma-dangle":["error","never"] } } ``` ``` D:\HBuilderX\plugins\npm\npm.cmd init -yes npm.cmd install webpack --save-dev npm.cmd install webpack-cli --save-dev "dev":"webpack", "dev1":"webpack --watch", "dev2":"webpack-dev-server --hot --mode development" npm.cmd install webpack-dev-server --save-dev 新建 src 新建 index.js 新建 hello.js npm.cmd install babel-core babel-loader --save-dev npm.cmd install babel-preset-es2015 babel-preset-react --save-dev .babelrc { "presets":["es2015","react"] } npm.cmd install eslint eslint-loader --save-dev eslint-webpack-plugin Please install eslint-plugin-jsx-a11y' Please use eslint-webpack-plugin npm.cmd install eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y --save-dev .eslintrc npm.cmd install eslint-config-airbnb --save-dev { "extends":"airbnb", "rules":{ "comma-dangle":["error","never"] } } npm.cmd install html-webpack-plugin --save-dev webpack.config.js webpack-cli --hot --mode development npm.cmd install react react-dom --save npm.cmd install babel-loader@7 --save-dev install webpack@5.57.1 -D npm.cmd install npm.cmd update npm.cmd run dev3 ```