EmilMoe's avatar
Level 10

npm run prod fails with Bootstrap

Can anyone explain to me what is going wrong here and how to fix it? The problem only occurs when I compile for production npm run prod never when I compile for development npm run dev, so it must be something to do with the minifications.

Screenshot 2020-01-07 at 08.35.08.png

As code:

ERROR in ./resources/sass/app.scss (./node_modules/css-loader??ref--5-2!./node_modules/postcss-loader/src??postcss0!./node_modules/resolve-url-loader??ref--5-4!./node_modules/sass-loader/dist/cjs.js??ref--5-5!./resources/sass/app.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
SyntaxError

(259:4) Unclosed block

  257 | 
  258 |   .navbar-toggler-icon {
> 259 |     background-image: escape-svg($navbar-light-toggler-icon-bg);
      |    ^
  260 |   }
  261 | 

 @ ./resources/sass/app.scss 2:14-253
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ 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`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/emil/.npm/_logs/2020-01-06T22_26_52_993Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 2
npm ERR! 
0 likes
8 replies
bobbybouwmann's avatar

Did you read the error? It says the problem occurs in resources/sass/app.scss

It probably has something to do with the escape-svg method here, nothing with bootstrap at least.

Is escape-svg a custom method? If so, you need to look into that. Also updating to the latest bootstrap might help as well ;)

EmilMoe's avatar
Level 10

Yes I know, but that function is a part of Bootstrap and nothing I have made

dulgheru.alex91@gmail.com's avatar

I have the same problem. After install laravel/ui i have this error. App.scss is fresh from laravel, if comment import bootstrap it works.

EmilMoe's avatar
Level 10

@alexd The only solution I have found myself was to downgrade a few things. I don't know exactly which one that does the trick:

"bootstrap": "^4.0.0",
"laravel-mix": "^4.0.7",
"sass": "^1.20.1",
"sass-loader": "7.*",
"cross-env": "^6.0.3",
dulgheru.alex91@gmail.com's avatar
Level 1

@emilmoe I found a temporary solution. You need to upgrade to "sass-loader": "^ 8.0.2", and then run "npm update -D". This works for me.

15 likes
EmilMoe's avatar
Level 10

Thanks @alexd I will select you as the best answer, however it seems to have fixed "itself" for me

Please or to participate in this conversation.