ixudra's avatar

Laravel Mix failures - possible dependency issue

I'm trying to manage my dependencies using Laravel Mix. Installing my dependencies works fine, however running npm run dev brings me to a world of trouble.

Here is my package.json file:

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "eonasdan-bootstrap-datetimepicker": "^4.17.0",
    "modernizr": "^3.3.1",
    "restfulizerjs": "^1.0.0",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

Here is my Laravel mix file:

let mix = require('laravel-mix');

var paths = {
    'bootstrap':        './node_modules/bootstrap-sass/assets/',
    'dateTimePicker':   './node_modules/eonasdan-bootstrap-datetimepicker/src/',
    'jquery':           './node_modules/jquery/',
    'modernizr':        './node_modules/modernizr/',
    'moment':           './node_modules/moment/',
    'momentTimezone':   './node_modules/moment-timezone/',
    'restfulizer':      './node_modules/restfulizerjs/'
};

mix

// Compile SASS files
    .sass('resources/assets/bootstrap/sass/app.scss', 'public/bootstrap/css/app.css')

    // Copy fonts to public directory
    .copy(paths.bootstrap + 'fonts/bootstrap/**', 'public/bootstrap/fonts')

    // Combine Javascript files
    .js([
        paths.jquery + "dist/jquery.js",
        paths.bootstrap + "javascripts/bootstrap.js",
        paths.moment + "moment.js",
        paths.dateTimePicker + "js/bootstrap-datetimepicker.js",
        paths.restfulizer + "jquery.restfulizer.js",
        "resources/assets/bootstrap/js/app.js"
    ], 'public/bootstrap/js/app.js', './')

    // Version stylesheet and javascript file
    .version();

The error that I get is the following:

$ npm run dev

> @ dev /var/www/my-hiddit/htdocs
> npm run development


> @ development /var/www/my-hiddit/htdocs
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.path: The provided value "public" is not an absolute path!

That brought me to these posts on the Laravel Mix github page. At first, it didn't seem to apply to me because I have Laravel mix at ^1.0 in my package.json file. But then I ran a node list --depth=0 and got the following:

$ npm list --depth=0
/var/www/my-hiddit/htdocs
├── [email protected] invalid
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] invalid
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

I've tried to fix this in any number of ways, but no matter what I do Laravel Mix always stays stuck at 0.7.5 - even if I fix the version or if I remove all other dependencies from the file. I assume this is what's causing my other problem but I have absolutely no idea why this is happening or how I can fix it.

Any help would be appreciated.

  • OS: Ubuntu 16
  • Ruby version: 2.3.1
  • Node version: 8.0.7
  • NPM version: 5.0.3
  • I am NOT using a custom webpack config file
0 likes
8 replies
kehator's avatar

As you mentioned - the webpack config file is custom, and the message you can see, says : "Invalid configuration object (...) The provided value "public" is not an absolute path"

There must be something wrong with the webpack config file. Can you put it here?

ixudra's avatar

@kehator I believe you misread: I am NOT using a custom webpack config file.

Cronix's avatar
], 'public/bootstrap/js/app.js', './')

what's the extra './' parameter for? mix.js() takes 2 parameters.

kehator's avatar

@Elimentz What a bummer :) sorry about that misreading :) My laravel mix is [email protected] and I can see my package.json pulling that command in devDependencies:

"laravel-mix": "0.*"

I can see 'invalid' axios and laravel-mix in your output. Did you tried to update theme manually or reinstalling them ?

@Cronix this is the path to the output file which is an absolute path

kehator's avatar

omg ... " - configuration.output.path: The provided value "public" is not an absolute path!"

and you have an absolute path there :D can you try to play up with it a bit? I just tested it and it should be fine, however my laravel-mix is 0.12.1

ixudra's avatar

@kehator To be honest: I'm about 98.749% sure the path problem will resolve itself as soon as I manage to update my Laravel mix to > 0.8, it's a know bug that @JeffreyWay actually added a fix for (see Github link in original post). I just have no idea what is going wrong here

ixudra's avatar
ixudra
OP
Best Answer
Level 4

It seems NodeJs was the problem here. I recently updated to Node 8.4.* and all my problems disappeared

Please or to participate in this conversation.