Skip to content

Error: invalid argument at pathToArray: node_modules/memory-fs/lib/MemoryFileSystem.js:44:10 #6

@Fr33maan

Description

@Fr33maan

Hi,

I see this error is already mentionned in two issues but I cannot find how to solve it.
I understand that there is a problem with path but I don't understand which one.

libre@me:~/dev/testapp$ sails lift

info: Starting app...

/home/libre/dev/testapp/node_modules/webpack-dev-middleware/middleware.js:106
                        if(err) throw err;
                                ^
Error: invalid argument
    at pathToArray (/home/libre/dev/testapp/node_modules/memory-fs/lib/MemoryFileSystem.js:44:10)

    at MemoryFileSystem.mkdirpSync (/home/libre/dev/testapp/node_modules/memory-fs/lib/MemoryFileSystem.js:139:13)
    at MemoryFileSystem.(anonymous function) [as mkdirp] (/home/libre/dev/testapp/node_modules/memory-fs/lib/MemoryFileSystem.js:279:34)
    at Compiler.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/Compiler.js:229:25)
    at Compiler.applyPluginsAsync (/home/libre/dev/testapp/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.emitAssets (/home/libre/dev/testapp/node_modules/webpack/lib/Compiler.js:226:7)
    at Watching.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/Compiler.js:54:18)
    at /home/libre/dev/testapp/node_modules/webpack/lib/Compiler.js:403:12
    at Compiler.next (/home/libre/dev/testapp/node_modules/tapable/lib/Tapable.js:67:11)
    at Compiler.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/CachePlugin.js:40:4)
    at Compiler.applyPluginsAsync (/home/libre/dev/testapp/node_modules/tapable/lib/Tapable.js:71:13)
    at Compiler.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/Compiler.js:400:9)
    at Compilation.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/Compilation.js:577:13)
    at Compilation.applyPluginsAsync (/home/libre/dev/testapp/node_modules/tapable/lib/Tapable.js:60:69)
    at Compilation.<anonymous> (/home/libre/dev/testapp/node_modules/webpack/lib/Compilation.js:572:10)
    at Compilation.applyPluginsAsync (/home/libre/dev/testapp/node_modules/tapable/lib/Tapable.js:60:69)

I've created a fresh sails app and only install this module + webpack + webpack-dev-server + less importer and I still get this issue.

I tried to remove all unnecessary things like sass, ttf, png, jpg, etc ...
I also created the assets/js/index.js file

I understand the point I'm missing. Very annoying to havn't this working out of the box.

// config/webpack.js
var webpack = require('webpack');
var path = require('path');
var LessPluginCleanCSS = require('less-plugin-clean-css');

var debug = process.env.NODE_ENV === 'development';
var entry = [
  path.resolve(__dirname, '../assets/js/index.js') // set your main javascript file
];
var plugins = [
  // prevents the inclusion of duplicate code into your bundle
  new webpack.optimize.DedupePlugin()
];

if (debug) {
  // add this entries in order to enable webpack HMR in browser
  entries.push('webpack/hot/dev-server');
  entries.push('webpack-dev-server/client?http://localhost:3000/');

  // HMR plugin
  plugins.push(new webpack.HotModuleReplacementPlugin({
    multiStep: true
  }));
} else {
  // Minify bundle (javascript and css)
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    minimize: true,
    output: { comments: false },
    compress: { drop_console: true }
  }));
}

module.exports.webpack = {
  config: { // webpack config begin here
    entry: entry,
    output: {
      path: path.resolve(__dirname, '../.tmp/public'), // sails.js public path
      filename: 'bundle.js' // or 'bundle-[hash].js'
    },
    debug: debug,
    plugins: plugins,
    module: {
      preLoaders: [
        {
          test: /.(jpg|jpeg|png|gif|svg)$/, // Minify images using imagemin
          loader: 'image-webpack', // npm install --save image-webpack-loader
          query: {
            bypassOnDebug: true // do not minify when is in development mode
          }
        }
      ],
      loaders: [ // not all are necessary, choose wisely
        {
          test: /\.less$/, // load LESS files
          loaders: [
            'style',
            'css',
            'autoprefixer?browsers=last 2 versions',
            'less?sourceMap' // npm install --save less-loader less
          ]
        }
      ]
    },
    lessLoader: { // config less-loader
      lessPlugins: [
        new LessPluginCleanCSS({advanced: true})
      ]
    },
    imageWebpackLoader: { // config image-webpack-loader
      optimizationLevel: 6, // imagemin options
      progressive: true,
      interlaced: true,
      pngquant: { // pngquant custom options
        quality: '65-90',
        speed: 4
      },
      svgo: { // svgo custom options
        plugins: [
          { removeViewBox: false },
          { removeUselessStrokeAndFill: false }
        ]
      }
    }
  }, // webpack config ends here
  development: { // dev server config
    webpack: { }, // separate webpack config for the dev server or defaults to the config above
    config: { // webpack-dev-server config
      // This is handy if you are using a html5 router.
      historyApiFallback: true,
      // set value port as 3000,
      // open your browser at http://localhost:3000/ instead of http://localhost:1337/
      // for develop and debug your application
      port: 3000,
      // enable Hot Module Replacement with dev-server
      hot: true,
      // sails.js public path
      contentBase: path.resolve(__dirname, '../.tmp/public'),
      // bypass sails.js server
      proxy: {
        '*': {
          target: 'http://localhost:1337'
        }
      }
    }
  },
  watchOptions: {
    aggregateTimeout: 300
  }
};

I've created a repo if you want.

Thanks for your help !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions