Webpack-dev-server: Trying to run webpack.config.js through Babel hook result in error

Created on 18 May 2015  路  4Comments  路  Source: webpack/webpack-dev-server

$ webpack-dev-server --config ./babel-register.js --inline --hot

./babel-register.js

require('babel/register');
require('./webpack.config.js');

error

/home/kaylee/project-x/node_modules/webpack/lib/NormalModuleFactory.js:42
        var elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
                              ^
TypeError: Cannot read property 'replace' of undefined
    at Tapable.<anonymous> (/home/kaylee/project-x/node_modules/webpack/lib/NormalModuleFactory.js:42:25)
    at Tapable.applyPluginsAsyncWaterfall (/home/kaylee/project-x/node_modules/webpack/node_modules/tapable/lib/Tapable.js:75:69)
    at Tapable.NormalModuleFactory.create (/home/kaylee/project-x/node_modules/webpack/lib/NormalModuleFactory.js:27:7)
    at Tapable.<anonymous> (/home/kaylee/project-x/node_modules/webpack/lib/Compilation.js:207:11)
    at /home/kaylee/project-x/node_modules/webpack/node_modules/async/lib/async.js:125:13
    at Array.forEach (native)
    at _each (/home/kaylee/project-x/node_modules/webpack/node_modules/async/lib/async.js:46:24)
    at Object.async.each (/home/kaylee/project-x/node_modules/webpack/node_modules/async/lib/async.js:124:9)
    at Tapable.Compilation.addModuleDependencies (/home/kaylee/project-x/node_modules/webpack/lib/Compilation.js:178:8)
    at Tapable.Compilation.processModuleDependencies (/home/kaylee/project-x/node_modules/webpack/lib/Compilation.js:164:7)

npm ERR! Linux 3.13.0-52-generic
npm ERR! argv "/home/kaylee/.nvm/versions/io.js/v2.0.1/bin/iojs" "/home/kaylee/.nvm/versions/io.js/v2.0.1/bin/npm" "run" "quick-start"
npm ERR! node v2.0.1
npm ERR! npm  v2.9.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] quick-start: `webpack-dev-server --config ./babel-register.js --inline --hot`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] quick-start script 'webpack-dev-server --config ./babel-register.js --inline --hot'.
npm ERR! This is most likely a problem with the irobot2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server --config ./babel-register.js --inline --hot
npm ERR! You can get their info via:
npm ERR!     npm owner ls irobot2
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/kaylee/project-x/npm-debug.log

Most helpful comment

@piratus where should I import the config?

All 4 comments

Looks like you should export the config

module.exports = require('webpack.config.js')

@piratus Yep you're right, I forgot to close this.

@piratus where should I import the config?

@piratus @gsklee where should I import the config?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gimmi picture gimmi  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

Ky6uk picture Ky6uk  路  3Comments

nikirossi picture nikirossi  路  3Comments

daryn-k picture daryn-k  路  3Comments