Laravel-mix: Failed to compile on Stand-Alone Project

Created on 17 Jun 2017  路  7Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.12.1 (npm list --depth=0)
  • Node Version (node -v): v7.8.0
  • NPM Version (npm -v): 4.2.0
  • OS: macOS Sierra 10.12.5

Description:

Failed to compile on non-laravel project

Steps To Reproduce:

mkdir my-app && cd my-app
npm init -y
npm install laravel-mix --save-dev
cp -r node_modules/laravel-mix/setup/** ./

Configuration:

webpack.mix.js

let mix = require('laravel-mix');
mix.js('src/app.js', 'build/')
   .sass('src/app.scss', 'build/');

package.json

{
    "name": "rating",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
        "watch": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules",
        "hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
        "production": "cross-env NODE_ENV=production webpack --progress --hide-modules"
    },
    "devDependencies": {
        "laravel-mix": "^0.12.1"
    }
}


Error

uonick ~/Projects/rating $ npm run dev

> [email protected] dev /Users/uonick/Projects/rating
> cross-env NODE_ENV=development webpack --progress --hide-modules

/Users/uonick/Projects/rating/node_modules/webpack/bin/convert-argv.js:492
                throw new Error("'output.filename' is required, either in config file or as --output-filename");
                ^

Error: 'output.filename' is required, either in config file or as --output-filename
    at processOptions (/Users/uonick/Projects/rating/node_modules/webpack/bin/convert-argv.js:492:11)
    at processConfiguredOptions (/Users/uonick/Projects/rating/node_modules/webpack/bin/convert-argv.js:141:4)
    at module.exports (/Users/uonick/Projects/rating/node_modules/webpack/bin/convert-argv.js:117:10)
    at Object.<anonymous> (/Users/uonick/Projects/rating/node_modules/webpack/bin/webpack.js:153:40)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

All 7 comments

Remove the trailing slashes.

@ruchern where?

let mix = require('laravel-mix');
mix.js('src/app.js', 'build/')
   .sass('src/app.scss', 'build/');

Remove trailing slashes for build/

thnx, but did not help:

screen shot 2017-06-17 at 05 35 54

Can you try this -
specify the output file name

mix.js('src/app.js', 'build/app.js')
   .sass('src/app.scss', 'build/app.css');

Found a solution:
in package.json:

...
"scripts": 
{
        "dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
...

},

--config=node_modules/laravel-mix/setup/webpack.config.js was added

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Micaso picture Micaso  路  3Comments

mementoneli picture mementoneli  路  3Comments

Bomavi picture Bomavi  路  3Comments

dtheb picture dtheb  路  3Comments

pixieaka picture pixieaka  路  3Comments