chrisdwheatley / netlify-plugin-image-optim

Optimize images as part of your Netlify build process. Optimizes PNG, JPEG, GIF and SVG file formats.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error `Cannot read property 'each' of undefined`

ehmicky opened this issue · comments

The following error happens in some builds:

Error in file: build/static/media/animated_logo.52e0714e.svg

Cannot read property 'each' of undefined 
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:26:31 Object.enter
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:11:16 Object.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:160:19 List.walkNode
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/common/List.js:158:12 List.each
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:106:29 Object.StyleSheet
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:163:37 walkNode
    /opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:219:9 Object.walk
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:18:13 Object.flattenToSelectors
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/plugins/inlineStyles.js:82:47 Object.exports.fn
    /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/svgo/plugins.js:95:27 

Full build logs:

6:35:53 PM: Build ready to start
6:35:55 PM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
6:35:55 PM: build-image tag: v3.3.19
6:35:55 PM: buildbot version: 8e2e5a3a5212190d0490c1372e313994f9085345
6:35:55 PM: Fetching cached dependencies
6:35:55 PM: Starting to download cache of 254.3KB
6:35:55 PM: Finished downloading cache in 61.124077ms
6:35:55 PM: Starting to extract cache
6:35:55 PM: Failed to fetch cache, continuing with build
6:35:55 PM: Starting to prepare the repo for build
6:35:55 PM: No cached dependencies found. Cloning fresh repo
6:35:55 PM: git clone https://github.com/ritesh007sharma/PersonalWebsite-package.json
6:35:57 PM: Preparing Git Reference refs/heads/master
6:35:59 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI
6:35:59 PM: Starting build script
6:35:59 PM: Installing dependencies
6:35:59 PM: Python version set to 2.7
6:36:00 PM: v12.18.0 is already installed.
6:36:01 PM: Now using node v12.18.0 (npm v6.14.4)
6:36:01 PM: Started restoring cached build plugins
6:36:01 PM: Finished restoring cached build plugins
6:36:01 PM: Attempting ruby version 2.7.1, read from environment
6:36:02 PM: Using ruby version 2.7.1
6:36:02 PM: Using PHP version 5.6
6:36:02 PM: 5.2 is already installed.
6:36:02 PM: Using Swift version 5.2
6:36:02 PM: Started restoring cached node modules
6:36:02 PM: Finished restoring cached node modules
6:36:02 PM: Installing NPM modules using NPM version 6.14.4
6:36:35 PM: > baseui@9.65.3 install /opt/build/repo/node_modules/baseui
6:36:35 PM: > node -e "console.log('If you are using Webpack, please make sure to update to version ^4.32.0, as this Base Web version depends on a webpack fix delivered in that version. If you are using Fusion.js make sure to upgrade fusion-cli to ^2.4.2 as it has the Webpack upgrade.')"
6:36:35 PM: If you are using Webpack, please make sure to update to version ^4.32.0, as this Base Web version depends on a webpack fix delivered in that version. If you are using Fusion.js make sure to upgrade fusion-cli to ^2.4.2 as it has the Webpack upgrade.
6:36:35 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
6:36:35 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:36:35 PM: > core-js@3.6.4 postinstall /opt/build/repo/node_modules/react-app-polyfill/node_modules/core-js
6:36:35 PM: > node -e "try{require('./postinstall')}catch(e){}"
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules/jest-haste-map/node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.7 (node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules/chokidar/node_modules/fsevents):
6:36:37 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
6:36:37 PM: added 1655 packages from 850 contributors and audited 1790 packages in 34.149s
6:36:39 PM: 45 packages are looking for funding
6:36:39 PM:   run `npm fund` for details
6:36:39 PM: found 4 vulnerabilities (1 low, 2 moderate, 1 high)
6:36:39 PM:   run `npm audit fix` to fix them, or `npm audit` for details
6:36:39 PM: NPM modules installed
6:36:39 PM: Started restoring cached go cache
6:36:39 PM: Finished restoring cached go cache
6:36:39 PM: go version go1.14.4 linux/amd64
6:36:39 PM: go version go1.14.4 linux/amd64
6:36:39 PM: Installing missing commands
6:36:39 PM: Verify run directory
6:36:40 PM: ​
6:36:40 PM: ┌─────────────────────────────┐
6:36:40 PM: │        Netlify Build        │
6:36:40 PM: └─────────────────────────────┘
6:36:40 PM: ​
6:36:40 PM: ❯ Version
6:36:40 PM:   @netlify/build 2.0.20
6:36:40 PM: ​
6:36:40 PM: ❯ Flags
6:36:40 PM:   deployId: 5efb69e9d6c52ea901143813
6:36:40 PM:   mode: buildbot
6:36:40 PM: ​
6:36:40 PM: ❯ Current directory
6:36:40 PM:   /opt/build/repo
6:36:40 PM: ​
6:36:40 PM: ❯ Config file
6:36:40 PM:   No config file was defined: using default values.
6:36:40 PM: ​
6:36:40 PM: ❯ Context
6:36:40 PM:   production
6:36:40 PM: ​
6:36:40 PM: ❯ Loading plugins
6:36:40 PM:    - netlify-plugin-gatsby-cache@0.3.0 from Netlify app
6:36:40 PM:    - @netlify/plugin-sitemap@0.3.4 from Netlify app
6:36:40 PM:    - netlify-plugin-image-optim@0.3.0 from Netlify app
6:36:41 PM: ​
6:36:41 PM: ┌────────────────────────────────────────────────────────┐
6:36:41 PM: │ 1. onPreBuild command from netlify-plugin-gatsby-cache │
6:36:41 PM: └────────────────────────────────────────────────────────┘
6:36:41 PM: ​
6:36:41 PM: No Gatsby cache found. Building fresh.
6:36:41 PM: ​
6:36:41 PM: (netlify-plugin-gatsby-cache onPreBuild completed in 251ms)
6:36:41 PM: ​
6:36:41 PM: ┌────────────────────────────────┐
6:36:41 PM: │ 2. Build command from settings │
6:36:41 PM: └────────────────────────────────┘
6:36:41 PM: ​
6:36:41 PM: $ npm run build
6:36:42 PM: > ritesh007sharma.github.io@0.1.0 build /opt/build/repo
6:36:42 PM: > react-scripts build
6:36:43 PM: Creating an optimized production build...
6:37:12 PM: Compiled successfully.
6:37:12 PM: 
6:37:12 PM: File sizes after gzip:
6:37:12 PM:   167.93 KB  build/static/js/2.6f967fcf.chunk.js
6:37:12 PM:   45.24 KB   build/static/js/main.c6e227c0.chunk.js
6:37:12 PM:   16.45 KB   build/static/css/main.a639f00b.chunk.css
6:37:12 PM:   785 B      build/static/js/runtime-main.0e64cde6.js
6:37:12 PM: The project was built assuming it is hosted at https://ritesh007sharma.github.io.
6:37:12 PM: You can control this with the homepage field in your package.json.
6:37:12 PM: The build folder is ready to be deployed.
6:37:12 PM: You may serve it with a static server:
6:37:12 PM:   npm install -g serve
6:37:12 PM:   serve -s build
6:37:12 PM: Find out more about deployment here:
6:37:12 PM:   https://bit.ly/CRA-deploy
6:37:12 PM: ​
6:37:12 PM: (build.command completed in 30.5s)
6:37:12 PM: ​
6:37:12 PM: ┌─────────────────────────────────────────────────────────┐
6:37:12 PM: │ 3. onPostBuild command from netlify-plugin-gatsby-cache │
6:37:12 PM: └─────────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:12 PM: Stored the Gatsby cache to speed up future builds.
6:37:12 PM: ​
6:37:12 PM: (netlify-plugin-gatsby-cache onPostBuild completed in 108ms)
6:37:12 PM: ​
6:37:12 PM: ┌─────────────────────────────────────────────────────┐
6:37:12 PM: │ 4. onPostBuild command from @netlify/plugin-sitemap │
6:37:12 PM: └─────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:12 PM: Creating sitemap from files...
6:37:12 PM: Sitemap Built! sitemap.xml
6:37:12 PM: ​
6:37:12 PM: (@netlify/plugin-sitemap onPostBuild completed in 40ms)
6:37:12 PM: ​
6:37:12 PM: ┌────────────────────────────────────────────────────────┐
6:37:12 PM: │ 5. onPostBuild command from netlify-plugin-image-optim │
6:37:12 PM: └────────────────────────────────────────────────────────┘
6:37:12 PM: ​
6:37:14 PM: ​
6:37:14 PM: ┌────────────────────────────────────────────────────┐
6:37:14 PM: │ Plugin "netlify-plugin-image-optim" internal error │
6:37:14 PM: └────────────────────────────────────────────────────┘
6:37:14 PM: ​
6:37:14 PM:   Error message
6:37:14 PM:   TypeError: Error in file: build/static/media/animated_logo.52e0714e.svg
6:37:14 PM: ​
6:37:14 PM:   Cannot read property 'each' of undefined
6:37:14 PM: ​
6:37:14 PM:   Plugin details
6:37:14 PM:   Package:        netlify-plugin-image-optim
6:37:14 PM:   Version:        0.3.0
6:37:14 PM:   Repository:     git+https://github.com/chrisdwheatley/netlify-plugin-image-optim.git
6:37:14 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-image-optim
6:37:14 PM:   Report issues:  https://github.com/chrisdwheatley/netlify-plugin-image-optim/issues
6:37:14 PM: ​
6:37:14 PM:   Error location
6:37:14 PM:   In "onPostBuild" event in "netlify-plugin-image-optim" from Netlify app
6:37:14 PM:       at Object.enter (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:26:31)
6:37:14 PM:       at Object.<anonymous> (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:11:16)
6:37:14 PM:       at List.walkNode (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:160:19)
6:37:14 PM:       at List.each (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/common/List.js:158:12)
6:37:14 PM:       at Object.StyleSheet (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:106:29)
6:37:14 PM:       at walkNode (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:163:37)
6:37:14 PM:       at Object.walk (/opt/buildhome/.netlify-build-plugins/node_modules/css-tree/lib/walker/create.js:219:9)
6:37:14 PM:       at Object.flattenToSelectors (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/css-tools.js:18:13)
6:37:14 PM:       at Object.exports.fn (/opt/buildhome/.netlify-build-plugins/node_modules/svgo/plugins/inlineStyles.js:82:47)
6:37:14 PM:       at /opt/buildhome/.netlify-build-plugins/node_modules/svgo/lib/svgo/plugins.js:95:27
6:37:14 PM: ​
6:37:14 PM:   Resolved config
6:37:14 PM:   build:
6:37:14 PM:     command: npm run build
6:37:14 PM:     publish: /opt/build/repo/build
6:37:14 PM:   plugins:
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: netlify-plugin-gatsby-cache
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: '@netlify/plugin-sitemap'
6:37:14 PM:     - inputs: {}
6:37:14 PM:       origin: ui
6:37:14 PM:       package: netlify-plugin-image-optim
6:37:14 PM: Caching artifacts
6:37:14 PM: Started saving node modules
6:37:14 PM: Finished saving node modules
6:37:14 PM: Started saving build plugins
6:37:14 PM: Finished saving build plugins
6:37:14 PM: Started saving pip cache
6:37:14 PM: Finished saving pip cache
6:37:14 PM: Started saving emacs cask dependencies
6:37:14 PM: Finished saving emacs cask dependencies
6:37:14 PM: Started saving maven dependencies
6:37:14 PM: Finished saving maven dependencies
6:37:14 PM: Started saving boot dependencies
6:37:14 PM: Finished saving boot dependencies
6:37:14 PM: Started saving go dependencies
6:37:14 PM: Finished saving go dependencies
6:37:17 PM: Error running command: Build script returned non-zero exit code: 1
6:37:17 PM: Failing build: Failed to build site
6:37:17 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
6:37:17 PM: Finished processing build request in 1m22.116204795s

The repository is private.
Do you know what the problem might be?