jeudi 4 juillet 2019

TypeError: Cannot read property 'push' of undefined in hjs-webpack

Following tutorial from Fullstack.io: create yelp clone

In my webpack.config.js file:

const webpack = require('webpack');
const fs = require('fs');
const path = require('path'),


join = path.join,
resolve = path.resolve;


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
    });


config.module.loaders.push({
    test: /\.css$/,
    include: [modules],
    loader: 'style!css'
  })


module.exports = config;

when running the dev. serve i get the following error:

TypeError: Cannot read property 'push' of undefined
    at Object.<anonymous> (E:\projects\React\yelpReact\webpack.config.js:90:22)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (E:\projects\React\yelpReact\node_modules\hjs-webpack\bin\hjs-dev-server.js:17:12)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
Failed to load webpack config, please use like this
hjs-dev-server.js webpack.config.js

turns out the config.module.loaders is returning null, what exactly am i doing wrong here, i never used used "hjs-webpack", appreciate any help




Aucun commentaire:

Enregistrer un commentaire