ERROR in TypeError: Cannot read property 'search' of undefined

#131 · closed · 5 comments

View on GitHub ↗

GiovanniL19

Hi, Could someone possibly help me out please? I am getting the following error and don't understand why: ``` ERROR in TypeError: Cannot read property 'search' of undefined at Object.eval (webpack:///(webpack)-dev-server/client?:31:28) at eval (webpack:///(webpack)-dev-server/client?:248:30) at Object../node_modules/webpack-dev-server/client/index.js?http://localhost:8081 (evalmachine.<anonymous>:276:1) at __webpack_require__ (evalmachine.<anonymous>:30:30) at eval (webpack:///multi_(webpack)-dev-server/client?:1:1) at Object.0 (evalmachine.<anonymous>:377:1) at __webpack_require__ (evalmachine.<anonymous>:30:30) at evalmachine.<anonymous>:79:18 at evalmachine.<anonymous>:82:10 at webpackUniversalModuleDefinition (evalmachine.<anonymous>:3:20) ``` The command I am using to start the server is `webpack-dev-server --mode development` The versions are: ``` static-site-generator-webpack-plugin: ^3.4.1 webpack-cli: ^2.1.3 webpack: ^4.8.1, webpack-dev-server: ^3.1.4 node: 8.11.1 ``` My webpack looks like this: ``` /*global require, module*/ const path = require("path") const ExtractTextPlugin = require("extract-text-webpack-plugin") const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin') module.exports = { entry: "./src/entry.js", output: { filename: 'index.js', path: path.resolve("dist"), libraryTarget: 'umd' }, module: { rules: [ { test: /\.scss$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: ["css-loader", "sass-loader"] }) }, { test: /\.css$/, use: [ { loader: "style-loader" }, { loader: "css-loader" } ] }, { test: /\.js$/, exclude: /node_modules/, use: "babel-loader" } ] }, plugins: [ new ExtractTextPlugin("dist/styles/main.css"), new StaticSiteGeneratorPlugin({ paths: [ '/' ], globals: { window: {} } }) ] } ``` And finally the entry file looks like this: ``` module.exports = function render(locals) { return '<html>Hello World</html>' } ``` I am grateful for any feedback regarding the issue I am having. This is the first time I am using this plugin.

Comments

GiovanniL19

Resolved [here](https://stackoverflow.com/questions/50326158/cannot-read-property-search-of-undefined-webpack-dev-server#comment87668304_50326158). I removed webpack-cli and used the following versions: ``` "webpack": "2.3.3", "webpack-dev-server": "1.16.4" ```

Mydayyy

I am currently facing the same issue as described here. Imho, downgrading webpack by two major versions is not an acceptable solution. Did anyone figure this out already?

e00dan

Hello, any solution to this?

Mydayyy

Use this plugin only in production, not together with the webpack dev server. Something like `!isDev ? staticSiteGeneratorPlugin : htmlWebPackPlugin` Feel free to take a look at my webpack config: https://github.com/Mydayyy/webpack4-react-boilerplate/blob/master/webpack.config.js

bz2

This can be avoided, even with latest webpack-dev-server, by not using the 'inline' option, using 'hot' is still fine. For example, in `package.json`: ```json "devDependencies": { "webpack-cli": "^3.1.2", "webpack-dev-server": "^3.1.9", ``` And in `webpack.conf.js`: ```javascript module.exports = { mode: 'development', devtool: 'eval', devServer: { inline: false, hot: true, }, ... ```