hjs-webpack icon indicating copy to clipboard operation
hjs-webpack copied to clipboard

Error in running ./node_modules/.bin/hjs-dev-server

Open blessingoraz opened this issue 8 years ago • 2 comments

Hello all,

I'm a newbie in React and I just came across the hjs-webpack plugin. I keep getting an error each time I run ./node_modules/.bin/hjs-dev-server on my terminal. Here is the error:

TypeError: Cannot read property 'https' of undefined

My webpack.config.js file is as follows:

const NODE_ENV = process.env.NODE_ENV;
const dotenv = require('dotenv');

const webpack = require('webpack');
const fs      = require('fs');
const path    = require('path'),
      join    = path.join,
      resolve = path.resolve;

const getConfig = require('hjs-webpack'); //configure our webpack

const isDev  = NODE_ENV === 'development';
const isTest = NODE_ENV === 'test';

const root    = resolve(__dirname);
const src     = join(root, 'src');
const modules = join(root, 'node_modules');
const dest    = join(root, 'dist');

var config = getConfig({
  isDev: isDev || isTest,
  in: join(src, 'app.js'),
  out: dest,
  clearBeforeBuild: true,
  html: function (context) {
    return {
      'index.html': context.defaultTemplate({
        title: 'yelp-clone from fullstackreact.com',
        publicPath: isDev ? 'http://localhost:3000/' : '',
        meta: {
          'name': 'fullstackreact yelp clone',
          'description': 'A minimal yelp clone from the team behind the fullstackreact.com book'
        }
      })
    }
  }
});
module.exports = config;

And my app.js is:

import React from 'react';
import ReactDOM from 'react-dom';

const App =  React.createClass({
  render: function() {
    return (
      <div>Hello world </div>
    );
  }
});

ReactDOM.render(<App />, document.querySelector("#root"));

I will really appreciate you if you can help me with this. Thank you!

blessingoraz avatar Sep 08 '16 08:09 blessingoraz

Getting the same error : E:\projects\React\yelpReact\node_modules\hjs-webpack\bin\hjs-dev-server.js:28 var https = serverConfig.https ^ TypeError: Cannot read property 'https' of undefined

my webpack.config.js:

const webpack = require('webpack');
const fs = require('fs');
const path = require('path'),
join = path.join,
resolve = path.resolve;

// create a few path variables to help us optimize our configuration
const root = resolve(__dirname);
const src = join(root, 'src');
const modules = join(root, 'node_modules');
const dest = join(root, 'dist');

const NODE_ENV = process.env.NODE_ENV;
const isDev = NODE_ENV === 'development';

const getConfig = require('hjs-webpack');
var config = getConfig({
    isDev: isDev,
    in: join(src, 'app.js'),// entry point file
    out: dest,
    // blow away any previously built files before it starts building new ones
    clearBeforeBuild: true
    })

module.exports = config;


package.json:


{
  "name": "yelpreact",
  "version": "1.0.0",
  "description": "yelp clone in react",
  "main": "webpack.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "SET NODE_ENV=development & hjs-dev-server"
  },

  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.6",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-hmre": "^1.1.1",
    "babel-preset-stage-0": "^6.24.1",
    "css-loader": "^2.1.1",
    "file-loader": "^3.0.1",
    "hjs-webpack": "^9.2.0",
    "postcss-loader": "^3.0.0",
    "style-loader": "^0.23.1",
    "url-loader": "^1.1.2",
    "webpack": "^4.32.2"
  },
  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-router": "^5.0.1"
  }
}

jimmyFlash avatar Jun 30 '19 12:06 jimmyFlash

Hi, was facing the same issue (mine was due to typo mistake). Try running NODE_ENV=development ./node_modules/hjs-webpack/bin/hjs-dev-server.js

hjs-webpack attachs the devServer property when isDev value is true.

Cryzek avatar Sep 28 '20 18:09 Cryzek