Gulp error: Path must be a string

2019-05-14 15:41发布

问题:

I've got a problem with gulp.js.

Steps to reproduce:

$ composer global require "laravel/installer=~1.1"
$ laravel new myproject
$ cd myproject
$ php artisan serve 
$ npm install
$ npm rm bootstrap-sass —save
$ npm install foundation-sites —save
$ npm install motion-ui —save

then I copy

_settings.scss 

from

node_modules/foundation-sites/scss/settings 

to

resources/assets/sass

in app.scss then i put every Foundation import

and finally I write Elixir task as reported here:

http://zecipriano.com/en/2015/12/laravel-elixir-and-zurb-foundation-revisited/

But when I launch gulp from terminal:

 path.js:7
  throw new TypeError('Path must be a string. Received ' + inspect(path));

... don't know what to do.

Everything updated, so I think it's not a version problem.

[EDIT]

$ node -v

v6.8.0

and here's my gulpfile.js:

const elixir = require('laravel-elixir');

require('laravel-elixir-vue-2');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function(mix) {

    // Sass
    var options = {
        includePaths: [
            'node_modules/foundation-sites/scss',
            'node_modules/motion-ui/src'
        ]
    };

    mix.sass('app.scss', null, options);

    // Javascript
    var jQuery = '../../../node_modules/jquery/dist/jquery.js';
    var foundationJsFolder = '../../../node_modules/foundation-sites/js/';

    mix.scripts([
       jQuery,
       foundationJsFolder + 'foundation.core.js',
       // Include any needed components here. The following are just examples.
       foundationJsFolder + 'foundation.util.mediaquery.js',
       foundationJsFolder + 'foundation.util.keyboard.js',
       foundationJsFolder + 'foundation.util.timerAndImageLoader.js',
       foundationJsFolder + 'foundation.tabs.js',
       // This file initializes foundation
       'start_foundation.js'
    ]);

});

Any ideas?

Thank you in advance.

回答1:

The problem is that the options have been moved from the third to the fourth parameter. You can run it with:

   mix.sass('app.scss', null, null, options);

Cheers :D



回答2:

I have the node 4.4.2 installed and countered the same error. Then I passed the the directory string directly instead of using an array with directions.