Nuxt.js: Nuxt build failing due to Terser

Created on 2 Feb 2019  ยท  26Comments  ยท  Source: nuxt/nuxt.js

Version

v2.4.2

Reproduction link

https://github.com/nuxt/create-nuxt-app

Steps to reproduce

Create a new project using npx and try to build.

What is expected ?

A successful build.

What is actually happening?

Build fails with error:

ERROR in baa9a7368c0a13e03198.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/usr/src/app/node_modules/terser-webpack-plugin/dist/minify.js:175:23)

Additional comments?

It looks like this is an upstream issue. After some time spent trying to figure out why my build was failing and not seeing any issues here, I figured I would open one with the link to what I believe the cause to be: https://github.com/webpack-contrib/terser-webpack-plugin/issues/66

Hopefully some other dev is saved some debug time!

This bug report is available on Nuxt community (#c8593)
bug-report

Most helpful comment

Okay, we got it. Now calm down everybody ๐Ÿ˜‰

A few things you guys should consider:

  1. There are things called lockfiles. If you haven't committed them to your Git repo, you now know why you should (read more here)
  2. For all people using Nuxt the first time or on a new project (especially @supersamka and @pavlushacoder), that's an unlucky start ๐Ÿ˜ฆ
  3. There are workarounds for that issue known
  4. Maintainers break things. That happens. They don't do that intentionally
  5. No Maintainers owes you anything. We all put a lot of time into our projects, be it Nuxt, Webpack or whatever. And you all can use them for free
  6. If you want that they owe you something, make a deal (e.g. a support contract or whatever) with them ๐Ÿคทโ€โ™‚๏ธ
  7. "Mimimi, 2 days without a fix how can you do that?!?!" will achieve nothing besides that maintainers get sick of such comments, the "community" (though the majority didn't do anything) and open source in general. STOP IT!

TL;DR

  • Use lockfiles
  • Be excellent to each other
  • Maintainers have a life as well
  • Use known workarounds (look here for example)

All 26 comments

backtrace:

ERROR in 70fe8ac2e7db24c37f38.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/home/simon/Dev/Web/hokify-pwa/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
at module.exports (/home/simon/Dev/Web/hokify-pwa/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/home/simon/Dev/Web/hokify-pwa/node_modules/worker-farm/lib/child/index.js:44:8)
at process. (/home/simon/Dev/Web/hokify-pwa/node_modules/worker-farm/lib/child/index.js:51:3)
at process.emit (events.js:188:13)
at emit (internal/child_process.js:828:12)
at process.internalTickCallback (internal/process/next_tick.js:72:19)

terser is accessed via ".default".. which is not defined though. If you change the line to (/home/simon/Dev/Web/hokify-pwa/node_modules/terser-webpack-plugin/dist/minify.js:175)

 const {
    error,
    map,
    code,
    warnings
  } = _terser.minify({
    [file]: input
  }, terserOptions);

thinks work again..

Adding

"resolutions": {
  "terser": "3.14.1"
}

to package.json helped me to successfully $ yarn build until this is fixed.

Similarly, hardcoding a dependency in my package.json worked for npm.

"dependencies":{
...
"terser": "3.14.1"
}

On Sat, 2 Feb 2019, 19:08 Marco Ehrenmann <[email protected] wrote:

Adding

"resolutions": {
"terser": "3.14.1"
}

to package.json helped me to successfully $ yarn build until this is
fixed.

โ€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/nuxt/nuxt.js/issues/4931#issuecomment-459990777, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGKQ68E-_fV6f9NG2jrVs7Bw4k175eokks5vJeIlgaJpZM4afsTd
.

@stepbeek Can you use yarn why terser and paste the result here ? It seems that something installed [email protected] and made somehow Nuxt use it instead of [email protected].

Thanks @mauxtin. Fix on his way : https://github.com/terser-js/terser/pull/254

But the issue it not around Nuxt dependencies, it's around a module/option selected through create-nuxt-app which depends on terser and probably updated it to last minor version under a patch version.

But I can't easily find which one, I would need someone with the issue to do yarn why terser.

@kevinmarrec "nuxt#@nuxt#webpack#terser-webpack-plugin" depends on it

@marcoeh Yeah thanks, just got that from yarn.lock:

terser-webpack-plugin@^1.1.0, terser-webpack-plugin@^1.2.1:
  version "1.2.1"
  resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.2.1.tgz#7545da9ae5f4f9ae6a0ac961eb46f5e7c845cc26"
  integrity sha512-GGSt+gbT0oKcMDmPx4SRSfJPE1XaN3kQRWG4ghxKQw9cn5G9x6aCKSsgYdvyM0na9NJ4Drv0RG6jbBByZ5CMjw==
  dependencies:
    cacache "^11.0.2"
    find-cache-dir "^2.0.0"
    schema-utils "^1.0.0"
    serialize-javascript "^1.4.0"
    source-map "^0.6.1"
    terser "^3.8.1"
    webpack-sources "^1.1.0"
    worker-farm "^1.5.2"

terser@^3.8.1:
  version "3.16.0"
  resolved "https://registry.yarnpkg.com/terser/-/terser-3.16.0.tgz#04028e6e5da461d91691cedd75fa53a17f2f20d9"
  integrity sha512-Ua8BhyibmsQBFXDZZ3Es7GASB2yFrQJr0jgAlZK1FBLbFarrHoCuMHPCro5MbX4jidcaFGiV+uTc3wxodmGjUg==
  dependencies:
    commander "~2.17.1"
    source-map "~0.6.1"
    source-map-support "~0.5.9"

I have the same issue! But with my current app, after I build it. I updated Nuxt and now I have this

ERROR in 22a950141f51121d5985.js from Terser
TypeError: Cannot read property 'minify' of undefined

And I also have font loader errors.

None of the mentioned solutions work for me, I just started an app with npx create-nuxt-app

$ npm ls terser
[email protected] /home/iom/code/app
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”ฌ @nuxt/[email protected]
    โ””โ”€โ”ฌ [email protected]
      โ””โ”€โ”€ [email protected] 
$ yarn why terser
yarn why v0.27.5
[1/4] Why do we have the module "terser"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "nuxt#@nuxt/webpack#terser-webpack-plugin" depends on it.
info Disk size without dependencies: "3.85MB"
info Disk size with unique dependencies: "4.84MB"
info Disk size with transitive dependencies: "4.85MB"
info Number of shared dependencies: 4
Done in 0.71s.

Edit: I was able to work around this by editing my yarn.lock file to resolve to the older version.

Still no fix, what a joke :smile:

Have a productive week, guys

@marcoeh you have something to tell me? Or you think it's normal to break millions of apps by not providing default export and not fixing it for days (it's will take like 15 minutes)? Everything not working, from create-react-app to Nuxt. All because of some dude forget to make default export.

@bdrtsk If it will take 15 minutes, raise a PR yourself.

Even better, it's already in progress :smiley:

@robcresswell yeah, PR :smile: It doesn't merged, that's the whole point. It's in progress for a 2 days already.

@marcoeh so? Let's break everything and then tell about personal life? If whole webpack ecosystem depends on that module, then why he's the only one who reviews PR's. You really think this is normal?

After watching Vuemastery tutorial about Nut I am trying to run npx create-nuxt-app and it's not working. Is this because of that? Can't understand (my first try of Nuxt)

@pavlushacoder that's an unfortunate first experience. I suggest you to wait a fix and then try again.

The root of problem is Terser, most if not all packages that depends on Terser have their build broken, Nuxt isn't the only one. A quick fix is to downgrade Terser's version by adding "terser": "3.14.1" in your dependencies. Please take a look at Terser's issues: https://github.com/terser-js/terser/issues

This is funny, since I also just tried to install Nuxt for the first time :smile:

@HoraceKeung did you tried it? We don't have Terser as dependency. This is dependency of dependency.

Sorry, I should have said it better, Nuxt does not directly depend on Terser, but Nuxt depends on something that depends on Terser. I had the same issue on Saturday, spent 2-3 hours looking for a fix, then I see Terser released 3.16.0 on Saturday (https://www.npmjs.com/package/terser), after reading a bit more, I tried adding "terser": "3.14.1" in my dependencies, and it worked.

The problem is he should have make it a major release i.e. make it version 4.0.0 then I believe none of these will happen.

Okay, we got it. Now calm down everybody ๐Ÿ˜‰

A few things you guys should consider:

  1. There are things called lockfiles. If you haven't committed them to your Git repo, you now know why you should (read more here)
  2. For all people using Nuxt the first time or on a new project (especially @supersamka and @pavlushacoder), that's an unlucky start ๐Ÿ˜ฆ
  3. There are workarounds for that issue known
  4. Maintainers break things. That happens. They don't do that intentionally
  5. No Maintainers owes you anything. We all put a lot of time into our projects, be it Nuxt, Webpack or whatever. And you all can use them for free
  6. If you want that they owe you something, make a deal (e.g. a support contract or whatever) with them ๐Ÿคทโ€โ™‚๏ธ
  7. "Mimimi, 2 days without a fix how can you do that?!?!" will achieve nothing besides that maintainers get sick of such comments, the "community" (though the majority didn't do anything) and open source in general. STOP IT!

TL;DR

  • Use lockfiles
  • Be excellent to each other
  • Maintainers have a life as well
  • Use known workarounds (look here for example)
 "resolutions": {
      "@nuxt/**/terser": "3.14.1"
  }

try this ? i resolved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  ยท  3Comments

msudgh picture msudgh  ยท  3Comments

bimohxh picture bimohxh  ยท  3Comments

jaredreich picture jaredreich  ยท  3Comments

o-alexandrov picture o-alexandrov  ยท  3Comments