Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property 'hot' of undefined #833

Closed
zackify opened this issue Mar 8, 2017 · 9 comments
Closed

Cannot set property 'hot' of undefined #833

zackify opened this issue Mar 8, 2017 · 9 comments

Comments

@zackify
Copy link

zackify commented Mar 8, 2017

What is the current behavior?

Getting:

TypeError: Cannot set property 'hot' of undefined
    at Server (/Users/zach/Projects/hyper-react/node_modules/webpack-dev-server/lib/Server.js:34:11)
    at _default (/Users/zach/Projects/hyper-react/dist/server.js:18:49)

When doing:

import Webpack from 'webpack-dev-server';
import WebpackDevServer from 'webpack-dev-server';
import config from './webpack.config';

export default () => {
  var server = new WebpackDevServer(Webpack(config), {
    hot: true,
    host: '0.0.0.0',
    contentBase: resolve(__dirname),
    publicPath: '/',
    historyApiFallback: {
      index: 'index.html',
    },
  });
  
  server.listen(8888, 'localhost', function() {});
};

Seems others are getting this too: webpack/webpack#2387

What is the expected behavior?

For the dev server to work.

Please mention your webpack and Operating System version.

webpack-dev-server 2.4.1, Mac OS Sierra

@SpaceK33z
Copy link
Member

import Webpack from 'webpack-dev-server';
import WebpackDevServer from 'webpack-dev-server';

The first one should be 'webpack'

@zackify
Copy link
Author

zackify commented Mar 8, 2017

Haha. This is what I get for coding too long. Thanks. This is embarrassing!

@zackify zackify closed this as completed Mar 8, 2017
@nsuedu
Copy link

nsuedu commented Jul 16, 2017

excuse me,i have same problem, can you tell me the solution?

@nsuedu
Copy link

nsuedu commented Jul 16, 2017

@zackify

@nsuedu
Copy link

nsuedu commented Jul 16, 2017

@SpaceK33z

@khurram-wasim
Copy link

khurram-wasim commented Jul 25, 2017

const express = require('express');
const webpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const app = express();

const compiler = webpack(webpackConfig);

app.use(express.static(__dirname + '/www'));

app.use(webpackDevServer(compiler, {
  hot: true,
  filename: 'bundle.js',
  publicPath: '/assets/',
  stats: {
    colors: true,
  },
  historyApiFallback: true,
}));

When I do npm start
I am getting this error Cannot set property 'hot' of undefined , any help to get rid of it ?

@shellscape
Copy link
Contributor

@ebardajiz probably 😄 but in all seriousness, try applying your config to a known-working use of the API by forking this repo and copying your config over to https://github.com/webpack/webpack-dev-server/tree/master/examples/node-api-simple. If it works, then it's something else in your project. If it doesn't work, then it's a webpack config issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@shellscape @zackify @SpaceK33z @nsuedu @khurram-wasim and others