SimonDegraeve / hapi-webpack-plugin

Webpack middleware for Hapi. Supports HMR.
57 stars 25 forks source link

Invalid path '' #1

Closed karlas closed 9 years ago

karlas commented 9 years ago

Hi,

I'm experiencing this error, and I can't guess how to solve it.

Error trace is:

/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack-dev-middleware/middleware.js:104
            if(err) throw err;
                          ^
Error: Invalid path ''
    at pathToArray (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:27:38)
    at MemoryFileSystem.mkdirpSync (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:111:13)
    at MemoryFileSystem.(anonymous function) [as mkdirp] (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack-dev-middleware/node_modules/memory-fs/lib/MemoryFileSystem.js:193:34)
    at Compiler.<anonymous> (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/lib/Compiler.js:229:25)
    at Compiler.applyPluginsAsync (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.emitAssets (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/lib/Compiler.js:226:7)
    at Watching.<anonymous> (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/lib/Compiler.js:54:18)
    at /home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/lib/Compiler.js:403:12
    at Compiler.next (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11)
    at Compiler.<anonymous> (/home/karlas/code/kaitocat/node_modules/hapi-webpack-plugin/node_modules/webpack/lib/CachePlugin.js:40:4)

This appears some seconds after registering, not inmediately. Register code is, at /src/server/index.js file of my project

  server.register(
  {
    register : require('hapi-webpack-plugin'),
    options  : path.join(__dirname, '../../webpack.config.js')
  }, function(err)
  {
    if (err)
    {
      return console.error(err);  //this is not reached
    }
  });

Webpack-dev-server is working fine when executing standalone via terminal. Could the problem be to have files in different paths? (webpack.config.js is at root of project)

Thanks in advance

karlas commented 9 years ago

By setting:

options : '../../webpack.config.js'

Error is :

Error: Configuration not found at ../../webpack.config.js

and setting

options : '.webpack.config.js'

Error is the same "Invalid path" error. So I guess path is relative from root of project

SimonDegraeve commented 9 years ago

Indeed, path is relative to process.cwd(), could be confusing. Maybe I should allow only absolute path...

karlas commented 9 years ago

Thanks for you time!

Unfortunately i'm getting same error (Invalid path "") and same trace.

Any clue?

SimonDegraeve commented 9 years ago

Can you share your webpack.config.js file?

karlas commented 9 years ago

Sure :

// webpack.config.js
var webpack = require('webpack');
var path    = require('path');
var isDev   = (process.env.NODE_ENV === 'dev');

var config  =
{
  entry   : {sobrassada : './client_js/sobrassada/main.js'},
  devtool : isDev ? 'source-map' : false,
  output  : isDev ? {filename: './public/sobrassada.js'} :
  {
    path          : './public/',
    publicPath    : './public/',
    chunkFilename : '[name].js',
    filename      : '[name].js'
  },
  module:
  {
    loaders:
    [
      {
        test    : /\.jsx?$/,
        exclude : /(node_modules)/,
        loader  : isDev ? 'react-hot!babel!eslint-loader' : 'babel'
      },
      {
        test   : /\.less$/,
        loader : "style!css!less"
      },
      //Fonts
      {
        test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=application/font-woff"
      },
      {
        test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=application/font-woff"
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=application/octet-stream"
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: "file"
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=image/svg+xml"
      }
    ]
  },
  plugins:
  [
    new webpack.DefinePlugin(
    {
      'process.env' : {'NODE_ENV': JSON.stringify(process.env.NODE_ENV)},
      __DEV__       : isDev,
    }),
  ]
};

if (isDev)
{
 config.plugins.push(new webpack.HotModuleReplacementPlugin());
 config.eslint = {configFile: '.eslintrc'};
}

module.exports = config;
SimonDegraeve commented 9 years ago

Ok, I am pretty sure it has nothing to do with the plugin. However in your config file I can see that output.path is not absolute, and it should be.

The output directory as absolute path (required).

From webpack configuration

karlas commented 9 years ago

Correct ;)

In fact, in dev mode i was noy specyficing any path, just filename.

Thanks!

SimonDegraeve commented 9 years ago

No problem.