Nuxt.js: The 91% chunk asset optimization problem

Created on 1 Mar 2018  ·  40Comments  ·  Source: nuxt/nuxt.js

Running npm run generate hangs at 91% (or 92%) chunk asset optimization. Works fine on Linux (using Solus) but freezes on WSL (Bash on Ubuntu on Windows).

Possible correlated issues:

  • webpack/webpack#4550
  • webpack/webpack#4558
  • webpack-contrib/babel-minify-webpack-plugin#49
  • mishoo/UglifyJS2#2609
  • JeffreyWay/laravel-mix#926
  • angular/angular-cli#5775
  • gdi2290/angular-starter#1925

I disabled UglifyJS using @Atinux method in nuxt/nuxt.js#250 and it built.

This question is available on Nuxt.js community (#c2535)
discussion

Most helpful comment

https://nuxtjs.org/api/configuration-build/#optimization

import TerserPlugin from 'terser-webpack-plugin'
build: {
    optimization: {
      minimize: true,
      minimizer: [
        new TerserPlugin({
          cache: true,
          parallel: false
        })
      ]
    }
}

It works on WSL. Nuxt version: 2.4.5.

All 40 comments

This is happening with me on my AWS EC2 instance, Ubuntu 16.04. Everything is up-to-date, sometimes it passes sometimes it just hangs at 91% additional asset processing and quits without any feedback.

Here you can see I tried twice, but no luck. It still quits unexpectedly without any error message, so I don't even know what's wrong.

ubuntu@xyz:/var/www/mywebsite.com$ npm run production

> @ production /var/www/mywebsite.com
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

ubuntu@xyz:/var/www/mywebsite.com$ npm run production

> @ production /var/www/mywebsite.com
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

ubuntu@xyz:/var/www/mywebsite.com$

I had same issue on my local, but I don't know why it run well without any issue on gitlab ci

It might be a memory issue. But on other threads I've seen people with good hardware configurations getting the same problem.

Just tried to add this option to my nuxt-config

module.exports = {
  build: {
    // ...

    uglify: {
      uglifyOptions: {
        compress: false
      },
      cache: '/path/to/cache/dir'
    },

    // ...
  },

  // ...
}

as suggested here and now it's working in my local.

Good for you, but I can't go without Uglify on production.

Same issue here, solution except disabling?

@feryardiant

Thanks. I solved my problem. :)

I added a swapfile on my VM and the process completed successfully. You guys should definitely give it a try.

Here are some good instructions on how to do it: How To Add Swap on Ubuntu

Using nuxt-edge resolved this issue for me at first.

But the issue randomly returned after working more on the project.

Running it in Bash, Ubuntu on Windows Linux Subsystem

EDIT: It's 100% WSL, Windows related. I build the exact same commit on Ubuntu Linux and it ran without any issues.

Only adding swap memory it's not the solution. The process at least should stop if the system is getting out of memory. On a continuous deployment environment this process is the devil. The compilation never end and of course the system is completely out of memory so no one can't connect to it until restarting the instance

I'm also having this issue under WSL.

Builds hanging at 91% on WSL as well (Ubuntu 18.04)

Build hanging at 90% (Ubuntu 16.04) not WSL

I'm also having this issue under WSL. at 91%

I resolved my issue by moving a lot of images from assets to static.

Resolved the issue by using nuxt-edge 2.1.0-25638752.fdb225f instead of nuxt 1.4.2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Hey guys! Who can provide me any manuals how to migrate from nuxt 1.4 to nuxt-edge?
We have a project based on nuxt kit (I got this package from github, with some preinstalled modules and properities). Now I got the same 91% problem. So if migration to nuxt 2 will resolve my problem I will give it a try. But I can't find any manuals for migration...
Help!!! Please...

resolved with migrate to nuxt edge

I'm having the same issue with v2.3.2.

I think its memory issue

Disabling minification (build.optimization.minimize) can help. https://nuxtjs.org/api/configuration-build/#optimization

migration on nuxt 2 resolved my problem

сб, 24 нояб. 2018 г. в 8:08, Alexander Lichter notifications@github.com:

Disabling minification (build.optimization.minimize) can help.
https://nuxtjs.org/api/configuration-build/#optimization


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nuxt/nuxt.js/issues/2921#issuecomment-441331644, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AosBy5u_WUNvIasNt77GYTuMyqke5bvsks5uyI3hgaJpZM4SXvmH
.

Disabling minification (build.optimization.minimize) can help. https://nuxtjs.org/api/configuration-build/#optimization

That's how I fixed the issue (along with updating to 2.3.2) :)

As described in the other issues linked above, it's a RAM issue. You can fix it by:

  • Adding more RAM
  • Adding a Disk Swap
  • Probably disabling minification

I add 4G swap.
And then I ran nuxt build.

Before
image

Building..
image

it was stopped at 91%.
image

Still running.
In my case, nuxt build do not use swap memory. (Why?)
image

As described in the other issues linked above, it's a RAM issue. You can fix it by:

  • Adding more RAM
  • Adding a Disk Swap
  • Probably disabling minification

RAM 8Gb, swap 24Gb
If exclude minification - fixed, but how whithout it

had this problem, using nuxt v2.3.4 on WSL

it works when i disable the minification, and my system has plenty of free memory to be used (~4GB) so cant be out of memory problem, how to solve this problem?

Still have this issue with the latest Nuxt version (2.3.4)

As described in the other issues linked above, it's a RAM issue. You can fix it by:

  • Adding more RAM
  • Adding a Disk Swap
  • Probably disabling minification
    image
    i think it's not the swap problem. my nuxt version is 2.0.0 and i can build in the production service machine. wsl which Ubuntu on the win10 can't build ,still 91%...

i soveld it in the window to build it.

https://nuxtjs.org/api/configuration-build/#optimization

import TerserPlugin from 'terser-webpack-plugin'
build: {
    optimization: {
      minimize: true,
      minimizer: [
        new TerserPlugin({
          cache: true,
          parallel: false
        })
      ]
    }
}

It works on WSL. Nuxt version: 2.4.5.

https://nuxtjs.org/api/configuration-build/#optimization

import TerserPlugin from 'terser-webpack-plugin'
build: {
    optimization: {
      minimize: true,
      minimizer: [
        new TerserPlugin({
          cache: true,
          parallel: false
        })
      ]
    }
}

it works in WSL. "nuxt": "2.4.5"

@laogui
Confirmed working in Nuxt 2.6.1 on WSL. The Swapfile solution higher in the thread didn't make a difference for me.

First, install Terser:

npm install terser-webpack-plugin --save-dev
or
yarn add terser-webpack-plugin

then copy/paste the above from @laogui .

Ah, even better. No need to install.

On Fri, Apr 19, 2019, 11:23 AM Alexander Lichter notifications@github.com
wrote:

You can also use https://nuxtjs.org/api/configuration-build/#terser I
guess.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nuxt/nuxt.js/issues/2921#issuecomment-484978025, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ALDCO46ARGQOUK44YBGFVF3PRIE3NANCNFSM4ES67GDQ
.

optimization: { minimize: false }

This will solve the problem

I suddenly have this issue after switching to postcss instead of scss and installing postcss-nested.

All the solutions above did't work for me, I ended up disabling uglify option on dev mode and now I can finally develop. It takes really long time to build on production though...

    extend (config, {isDev}) {
      if (isDev) { // in my case I couldn't use isDev so I used `process.env.NODE_ENV === 'development'`
        config.plugins = config.plugins.filter((plugin) => plugin.constructor.name !== 'UglifyJsPlugin')
      }

I took filtering uglify from another issue: How could i disable UglifyJs in the client webpack config? · Issue #250 · nuxt/nuxt.js

Is this issue solved in the latest version of nuxt?

uglify

does not work in nuxt 2.*

I was stepping onto the same issue.

It seems to work when I remove the dist directory before running nuxt-ts generate

"generate": "rm -rf dist && nuxt-ts generate",

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattdharmon picture mattdharmon  ·  3Comments

vadimsg picture vadimsg  ·  3Comments

vadimsg picture vadimsg  ·  3Comments

bimohxh picture bimohxh  ·  3Comments

maicong picture maicong  ·  3Comments