Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt build failing due to Terser #4931

Closed
stepbeek opened this issue Feb 2, 2019 · 26 comments
Closed

Nuxt build failing due to Terser #4931

stepbeek opened this issue Feb 2, 2019 · 26 comments

Comments

@stepbeek
Copy link

stepbeek commented Feb 2, 2019

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: webpack-contrib/terser-webpack-plugin#66

Hopefully some other dev is saved some debug time!

This bug report is available on Nuxt community (#c8593)
@ghost ghost added the cmty:bug-report label Feb 2, 2019
@simllll
Copy link

simllll commented Feb 2, 2019

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..

@marcoeh
Copy link

marcoeh commented Feb 2, 2019

Adding

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

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

@stepbeek
Copy link
Author

stepbeek commented Feb 2, 2019 via email

@kevinmarrec
Copy link
Contributor

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

@mauxtin
Copy link

mauxtin commented Feb 2, 2019

Related: vuejs/vue-cli#3407

@kevinmarrec
Copy link
Contributor

Thanks @mauxtin. Fix on his way : terser/terser#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.

@marcoeh
Copy link

marcoeh commented Feb 2, 2019

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

@kevinmarrec
Copy link
Contributor

kevinmarrec commented Feb 2, 2019

@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"

@bdrtsky
Copy link

bdrtsky commented Feb 3, 2019

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.

@carcinocron
Copy link

carcinocron commented Feb 3, 2019

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

$ npm ls terser
textsort@1.0.0 /home/iom/code/app
└─┬ nuxt@2.4.2
  └─┬ @nuxt/webpack@2.4.2
    └─┬ terser-webpack-plugin@1.2.1
      └── terser@3.16.0 
$ 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.

@bdrtsky

This comment has been minimized.

@bdrtsky

This comment has been minimized.

@marcoeh
Copy link

marcoeh commented Feb 4, 2019

terser/terser#254 (comment)

@robcresswell
Copy link

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

@robcresswell
Copy link

Even better, it's already in progress 😃

@bdrtsky
Copy link

bdrtsky commented Feb 4, 2019

@robcresswell yeah, PR 😄 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?

@pavlushacoder
Copy link

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)

@aedig
Copy link

aedig commented Feb 4, 2019

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

@HoraceKeung
Copy link

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

@supersamka
Copy link

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

@bdrtsky
Copy link

bdrtsky commented Feb 4, 2019

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

@HoraceKeung
Copy link

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.

@HoraceKeung
Copy link

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.

@nuxt nuxt locked as too heated and limited conversation to collaborators Feb 4, 2019
@manniL
Copy link
Member

manniL commented Feb 4, 2019

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)

@nuxt nuxt deleted a comment from bdrtsky Feb 4, 2019
@nuxt nuxt deleted a comment from HoraceKeung Feb 4, 2019
@manniL
Copy link
Member

manniL commented Feb 4, 2019

terser/terser#251 / https://www.npmjs.com/package/terser/v/3.16.1

Terser v3.16.1 resolves the issue

@manniL manniL closed this as completed Feb 4, 2019
@nuxt nuxt unlocked this conversation Feb 4, 2019
@nuxt nuxt deleted a comment from bdrtsky Feb 4, 2019
@manniL manniL unpinned this issue Feb 4, 2019
@kiloc
Copy link

kiloc commented Nov 21, 2019

 "resolutions": {
      "@nuxt/**/terser": "3.14.1"
  }

try this ? i resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests