Laravel-mix: Sass is required even if is not used

Created on 11 Dec 2018  路  3Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 4.0.2
  • Node Version (node -v): 8.11:4
  • NPM Version (npm -v): 6.4.1
  • OS: Windows 10

Description:

I have only js, less and Vue files in application but still error occurs that missing 'sass' dependencies. I have no sass in webpack.mix.js and also in the project.

After I install sass and sass-loader everything working fine. But it is strange I must install this even if I dont use them. Maybe it is bug so I report it. :)

I have one more project where I acctualy use sass and there was upgrade so simple. Great job.

Most helpful comment

Commit 8a8aa5a did not fix this.

Recently upgraded to v4:

npm remove laravel-mix
npm install laravel-mix@^4.0.0
npm install cross-env@^5.1.6

When running npm run dev it stops because it can't find the sass module.

> Error: Cannot find module 'sass'

webpack.mix.js file:

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

mix.less('resources/assets/client/app.less', 'public/builds-css/client.css');
mix.less('resources/assets/admin/app.less', 'public/builds-css/admin.css');
mix.less('resources/assets/main/app.less', 'public/builds-css/app.css');

mix.js('resources/assets/admin/app.js', 'public/builds-js/admin.js');
mix.js('resources/assets/main/app.js', 'public/builds-js/app.js');

mix.disableSuccessNotifications();

if (mix.inProduction()) {
    mix.options({ clearConsole: false, processCssUrls: false });
    mix.sourceMaps().version();
}

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": "npm run development -- --watch",
        "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 --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "cross-env": "^5.1.6",
        "laravel-mix": "^4.0.0",
        "less": "^3.9.0",
        "less-loader": "^4.1.0"
    },
    "dependencies": {}
}

@JeffreyWay

All 3 comments

Commit 8a8aa5a did not fix this.

Recently upgraded to v4:

npm remove laravel-mix
npm install laravel-mix@^4.0.0
npm install cross-env@^5.1.6

When running npm run dev it stops because it can't find the sass module.

> Error: Cannot find module 'sass'

webpack.mix.js file:

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

mix.less('resources/assets/client/app.less', 'public/builds-css/client.css');
mix.less('resources/assets/admin/app.less', 'public/builds-css/admin.css');
mix.less('resources/assets/main/app.less', 'public/builds-css/app.css');

mix.js('resources/assets/admin/app.js', 'public/builds-js/admin.js');
mix.js('resources/assets/main/app.js', 'public/builds-js/app.js');

mix.disableSuccessNotifications();

if (mix.inProduction()) {
    mix.options({ clearConsole: false, processCssUrls: false });
    mix.sourceMaps().version();
}

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": "npm run development -- --watch",
        "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 --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "cross-env": "^5.1.6",
        "laravel-mix": "^4.0.0",
        "less": "^3.9.0",
        "less-loader": "^4.1.0"
    },
    "dependencies": {}
}

@JeffreyWay

@JeffreyWay can we have this fixed? Thank you!

I'm also having this same issue. I've worked around it by just installing sass in my project, installing sass-loader wasn't even necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpmurray picture jpmurray  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

wendt88 picture wendt88  路  3Comments

sdebacker picture sdebacker  路  3Comments

amin101 picture amin101  路  3Comments