Skip to content

TypeError: Cannot read property 'minify' of undefined at minify with terser plugin #11508

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

Closed
itfarrier opened this issue Feb 2, 2019 · 7 comments
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: upstream Issues outside of Gatsby's control, caused by dependencies

Comments

@itfarrier
Copy link

itfarrier commented Feb 2, 2019

Description

Production build doesn't build, but dev build is good

Steps to reproduce

Just run gatsby build

P. S. This is after update
Part of yarn.lock before update while everything's works (good prod build without any errors)

terser@^3.8.1:
  version "3.14.1"
  resolved "https://registry.yarnpkg.com/terser/-/terser-3.14.1.tgz#cc4764014af570bc79c79742358bd46926018a32"
  integrity sha512-NSo3E99QDbYSMeJaEk9YW2lTg3qS9V0aKGlb+PlOrei1X02r1wSBHCNX/O+yeTRFSWPKPIGj6MqvvdqV4rnVGw==
  dependencies:
    commander "~2.17.1"
    source-map "~0.6.1"
    source-map-support "~0.5.6"

After update we have this (errors in "Environment" section below)

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"

Expected result

Prod build

Actual result

Prod build with error on js stage

Environment

gatsby info --clipboard


  System:
    OS: Linux 4.4 Ubuntu 16.04.5 LTS (Xenial Xerus)
    CPU: (4) x64 AMD Athlon(tm) X4 860K Quad Core Processor
    Shell: 5.1.1 - /usr/bin/zsh
  Binaries:
    Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
    Yarn: 1.13.0 - ~/.nvm/versions/node/v10.15.1/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v10.15.1/bin/npm
  Languages:
    Python: 2.7.12 - /usr/bin/python
  Browsers:
    Chrome: 72.0.3626.81
    Firefox: 65.0
  npmPackages:
    gatsby: ^2.0.111 => 2.0.111 
    gatsby-image: ^2.0.29 => 2.0.29 
    gatsby-plugin-i18n: ^1.0.1 => 1.0.1 
    gatsby-plugin-manifest: ^2.0.17 => 2.0.17 
    gatsby-plugin-offline: ^2.0.22 => 2.0.22 
    gatsby-plugin-postcss: ^2.0.5 => 2.0.5 
    gatsby-plugin-react-helmet: ^3.0.6 => 3.0.6 
    gatsby-plugin-sharp: ^2.0.20 => 2.0.20 
    gatsby-plugin-typescript: ^2.0.6 => 2.0.6 
    gatsby-remark-images: ^3.0.3 => 3.0.3 
    gatsby-source-filesystem: ^2.0.20 => 2.0.20 
    gatsby-transformer-remark: ^2.2.3 => 2.2.3 
    gatsby-transformer-sharp: ^2.1.13 => 2.1.13 
  npmGlobalPackages:
    gatsby-cli: 2.4.8

gatsby build --verbose

yarn run v1.13.0
$ yarn run clean && yarn run build && gatsby serve --verbose
$ rm -rf ./.cache/* && rm -rf ./public/*
$ gatsby build --verbose
verbose 0.657 set gatsby_log_level: "verbose"
verbose 0.66 set gatsby_executing_command: "build"
verbose 0.661 loading local command from: /home/ubuntu/pet/podabed.org/node_modules/gatsby/dist/commands/build.js
verbose 1.946 running command: build
success open and validate gatsby-configs — 0.014 s
success load plugins — 0.295 s
success onPreInit — 0.968 s
success delete html and css files from previous builds — 0.006 s
success initialize cache — 0.007 s
success copy gatsby files — 0.146 s
success onPreBootstrap — 0.009 s
success source and transform nodes — 0.487 s
success building schema — 0.322 s
success createPages — 0.089 s
success createPagesStatefully — 0.041 s
success onPreExtractQueries — 0.003 s
success update schema — 0.218 s
success extract queries from components — 0.143 s
success run graphql queries — 3.359 s — 54/54 16.08 queries/second
success write out page data — 0.003 s
success write out redirect data — 0.000 s


info bootstrap finished - 85.671 s

success onPostBootstrap — 0.005 s

error Generating JavaScript bundles failed


  Error: 0-605ebb314b340a3fdb75.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: app-9f97c9fcff725b10d2d8.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---node-modules-gatsby-plugin-offline-app-shell-js-91bd728d3d0  b9d6d10d8.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-404-tsx-a8a926f03b8bdceea050.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-about-tsx-92da9f3f2ee42b753bdd.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-blog-tsx-db2a6de4c1c183b55120.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-books-tsx-122cef08d0229fd13227.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-index-tsx-53d17582f9ddd1d608d9.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-inscriptions-tsx-a32f8aeb1451b65c35b9.js from Ter  ser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-video-tsx-516e158716eea7406f3c.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-pages-wishlist-tsx-f551164ed8439f493ebe.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: component---src-templates-post-tsx-55b144e1e1e4be5739e5.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: pages-manifest-9d4e09a33285956e2def.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)



  Error: webpack-runtime-c06633d0419170ab8da4.js from Terser
  TypeError: Cannot read property 'minify' of undefined
      at minify (/home/ubuntu/pet/podabed.org/node_modules/terser-webpack-plugin  /dist/minify.js:175:23)
      at module.exports (/home/ubuntu/pet/podabed.org/node_modules/terser-webpac  k-plugin/dist/worker.js:13:40)
      at handle (/home/ubuntu/pet/podabed.org/node_modules/worker-farm/lib/child  /index.js:44:8)
      at process.<anonymous> (/home/ubuntu/pet/podabed.org/node_modules/worker-f  arm/lib/child/index.js:51:3)
      at process.emit (events.js:189:13)
      at emit (internal/child_process.js:820:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Process finished with exit code 1
@devndive
Copy link

devndive commented Feb 2, 2019

I get the same errors with the latest packges - reverting to the versions I had before avoids this error.

Working setup
gatsby info --clipboard

  System:
    OS: macOS 10.14.2
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.7 - /usr/local/bin/zsh
  Binaries:
    Node: 11.9.0 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.5.0 - /usr/local/bin/npm
  Languages:
    Python: 2.7.15 - /usr/local/bin/python
  Browsers:
    Chrome: 72.0.3626.81
    Firefox: 64.0.2
    Safari: 12.0.2
  npmPackages:
    gatsby: ^2.0.85 => 2.0.85
    gatsby-image: ^2.0.20 => 2.0.25
    gatsby-plugin-manifest: ^2.0.9 => 2.0.13
    gatsby-plugin-offline: ^2.0.16 => 2.0.21
    gatsby-plugin-react-helmet: ^3.0.2 => 3.0.5
    gatsby-plugin-sharp: ^2.0.14 => 2.0.17
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
    gatsby-remark-autolink-headers: ^2.0.12 => 2.0.12
    gatsby-remark-images: ^3.0.1 => 3.0.1
    gatsby-remark-katex: ^3.0.1 => 3.0.1
    gatsby-remark-prismjs: ^3.2.0 => 3.2.0
    gatsby-remark-smartypants: ^2.0.7 => 2.0.7
    gatsby-source-filesystem: ^2.0.12 => 2.0.12
    gatsby-transformer-remark: ^2.1.19 => 2.1.19
    gatsby-transformer-sharp: ^2.1.8 => 2.1.10
    gatsby-transformer-yaml: ^2.1.6 => 2.1.6
  npmGlobalPackages:
    gatsby-cli: 2.4.8

Broken setup (npmPackages only, rest is the same as above)

  npmPackages:
    gatsby: ^2.0.85 => 2.0.111
    gatsby-image: ^2.0.20 => 2.0.29
    gatsby-plugin-manifest: ^2.0.9 => 2.0.17
    gatsby-plugin-offline: ^2.0.16 => 2.0.22
    gatsby-plugin-react-helmet: ^3.0.2 => 3.0.6
    gatsby-plugin-sharp: ^2.0.14 => 2.0.20
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.5
    gatsby-remark-autolink-headers: ^2.0.12 => 2.0.13
    gatsby-remark-images: ^3.0.1 => 3.0.3
    gatsby-remark-katex: ^3.0.1 => 3.0.3
    gatsby-remark-prismjs: ^3.2.0 => 3.2.4
    gatsby-remark-smartypants: ^2.0.7 => 2.0.8
    gatsby-source-filesystem: ^2.0.12 => 2.0.20
    gatsby-transformer-remark: ^2.1.19 => 2.2.3
    gatsby-transformer-sharp: ^2.1.8 => 2.1.13
    gatsby-transformer-yaml: ^2.1.6 => 2.1.8

@deammer
Copy link
Contributor

deammer commented Feb 2, 2019

Looks like a problem with terser-webpack-plugin:
terser/terser#254

Here's the simplest workaround at the moment:

# npm
npm i --save-exact --save terser@3.14

# yarn
yarn add terser@3.14 --exact

@swyxio
Copy link
Contributor

swyxio commented Feb 3, 2019

yes terser broke webpack. should be tempoorary. related issues: terser/terser#251

@ycjcl868
Copy link

ycjcl868 commented Feb 3, 2019

The project generated by scaffold reported.

@rdela
Copy link
Contributor

rdela commented Feb 3, 2019

deammer's suggested workaround above did not help build succeed for me but pitops suggestion on terser-webpack-plugin did:

As a workaround for now if you use yarn you can add a resolution to a fixed terser version. Delete yarn.lock first and node_modules

Example (in your package.json)

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

YMMV but thought I would drop it in here in case it helps someone else.

akselinurmio added a commit to demoniry/demoni-www-next that referenced this issue Feb 4, 2019
akselinurmio added a commit to demoniry/demoni-www-next that referenced this issue Feb 4, 2019
@sidharthachatterjee sidharthachatterjee added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: upstream Issues outside of Gatsby's control, caused by dependencies labels Feb 4, 2019
@sidharthachatterjee
Copy link
Contributor

This was fixed in terser/terser@03b0876

Updating terser to v3.16.1 should fix this, closing this for now

Updating our terser-webpack-plugin dependency to always be higher than 1.2.2 so no one sees this anymore

@rzubrycki
Copy link

terser is on 5.5.0 still broken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: upstream Issues outside of Gatsby's control, caused by dependencies
Projects
None yet
Development

No branches or pull requests

8 participants