TypeError: Cannot read properties of undefined (reading 'request')

HI! I get this error when trying to build from github…

the site name: relaxed-lamport-e120eb

and the log.
hope someone can help me out!
Thanks in advance!!

9:12:04 PM: Build ready to start
9:12:07 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
9:12:07 PM: build-image tag: v4.5.3
9:12:07 PM: buildbot version: 693324cfe3be8010187ffccaa57e996acc42169f
9:12:07 PM: Fetching cached dependencies
9:12:07 PM: Failed to fetch cache, continuing with build
9:12:07 PM: Starting to prepare the repo for build
9:12:08 PM: No cached dependencies found. Cloning fresh repo
9:12:08 PM: git clone https://github.com/Posoroko/cariboutou
9:12:08 PM: Preparing Git Reference refs/heads/master
9:12:09 PM: Parsing package.json dependencies
9:12:10 PM: Starting build script
9:12:10 PM: Installing dependencies
9:12:10 PM: Python version set to 2.7
9:12:11 PM: Downloading and installing node v16.14.0...
9:12:11 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...
9:12:11 PM: Computing checksum with sha256sum
9:12:12 PM: Checksums matched!
9:12:15 PM: Now using node v16.14.0 (npm v8.3.1)
9:12:16 PM: Started restoring cached build plugins
9:12:16 PM: Finished restoring cached build plugins
9:12:16 PM: Attempting ruby version 2.7.2, read from environment
9:12:17 PM: Using ruby version 2.7.2
9:12:18 PM: Using PHP version 8.0
9:12:18 PM: Started restoring cached node modules
9:12:18 PM: Finished restoring cached node modules
9:12:18 PM: Installing NPM modules using NPM version 8.3.1
9:12:29 PM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
9:12:30 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
9:12:30 PM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
9:12:30 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
9:12:30 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
9:12:31 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
9:12:33 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
9:12:36 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:12:38 PM: npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported
9:12:40 PM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
9:12:40 PM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
9:12:41 PM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
9:12:42 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
9:12:42 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
9:12:42 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
9:12:43 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
9:12:43 PM: npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
9:12:48 PM: added 1265 packages, and audited 1266 packages in 30s
9:12:48 PM: 84 packages are looking for funding
9:12:48 PM:   run `npm fund` for details
9:12:49 PM: 29 vulnerabilities (2 low, 17 moderate, 10 high)
9:12:49 PM: To address issues that do not require attention, run:
9:12:49 PM:   npm audit fix
9:12:49 PM: To address all issues (including breaking changes), run:
9:12:49 PM:   npm audit fix --force
9:12:49 PM: Run `npm audit` for details.
9:12:49 PM: NPM modules installed
9:12:49 PM: Started restoring cached go cache
9:12:49 PM: Finished restoring cached go cache
9:12:49 PM: go version go1.16.5 linux/amd64
9:12:49 PM: go version go1.16.5 linux/amd64
9:12:49 PM: Installing missing commands
9:12:49 PM: Verify run directory
9:12:51 PM: ​
9:12:51 PM: ────────────────────────────────────────────────────────────────
9:12:51 PM:   Netlify Build                                                 
9:12:51 PM: ────────────────────────────────────────────────────────────────
9:12:51 PM: ​
9:12:51 PM: ❯ Version
9:12:51 PM:   @netlify/build 26.3.9
9:12:51 PM: ​
9:12:51 PM: ❯ Flags
9:12:51 PM:   baseRelDir: true
9:12:51 PM:   buildId: 62193814bdcfe91a0af61610
9:12:51 PM:   deployId: 62193814bdcfe91a0af61612
9:12:51 PM: ​
9:12:51 PM: ❯ Current directory
9:12:51 PM:   /opt/build/repo
9:12:51 PM: ​
9:12:51 PM: ❯ Config file
9:12:51 PM:   No config file was defined: using default values.
9:12:51 PM: ​
9:12:51 PM: ❯ Context
9:12:51 PM:   production
9:12:51 PM: ​
9:12:51 PM: ────────────────────────────────────────────────────────────────
9:12:51 PM:   1. Build command from Netlify app                             
9:12:51 PM: ────────────────────────────────────────────────────────────────
9:12:51 PM: ​
9:12:51 PM: $ npm run build
9:12:52 PM: > cariboutou@0.1.0 build
9:12:52 PM: > vue-cli-service build
9:12:52 PM: -  Building for production...
9:13:07 PM:  ERROR  TypeError: Cannot read properties of undefined (reading 'request')
9:13:07 PM: TypeError: Cannot read properties of undefined (reading 'request')
9:13:07 PM:     at transform (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/transformers/moduleNotFound.js:17:61)
9:13:07 PM:     at transform (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/core/transformErrors.js:28:45)
9:13:07 PM:     at Array.reduce (<anonymous>)
9:13:07 PM:     at applyTransformations (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/core/transformErrors.js:29:56)
9:13:07 PM:     at Array.map (<anonymous>)
9:13:07 PM:     at processErrors (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/core/transformErrors.js:31:35)
9:13:07 PM:     at FriendlyErrorsWebpackPlugin.displayErrors (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/friendly-errors-plugin.js:97:29)
9:13:07 PM:     at doneFn (/opt/build/repo/node_modules/@soda/friendly-errors-webpack-plugin/src/friendly-errors-plugin.js:52:14)
9:13:07 PM:     at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:18:1)
9:13:07 PM:     at AsyncSeriesHook.lazyCompileHook (/opt/build/repo/node_modules/tapable/lib/Hook.js:154:20)
9:13:07 PM:     at onCompiled (/opt/build/repo/node_modules/webpack/lib/Compiler.js:271:21)
9:13:07 PM:     at /opt/build/repo/node_modules/webpack/lib/Compiler.js:681:15
9:13:07 PM:     at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
9:13:07 PM:     at AsyncSeriesHook.lazyCompileHook (/opt/build/repo/node_modules/tapable/lib/Hook.js:154:20)
9:13:07 PM:     at /opt/build/repo/node_modules/webpack/lib/Compiler.js:678:31
9:13:07 PM:     at AsyncSeriesHook.eval [as callAsync] (eval at create (/opt/build/repo/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
9:13:07 PM: ​
9:13:07 PM: ────────────────────────────────────────────────────────────────
9:13:07 PM:   "build.command" failed                                        
9:13:07 PM: ────────────────────────────────────────────────────────────────
9:13:07 PM: ​
9:13:07 PM:   Error message
9:13:07 PM:   Command failed with exit code 1: npm run build
9:13:07 PM: ​
9:13:07 PM:   Error location
9:13:07 PM:   In Build command from Netlify app:
9:13:07 PM:   npm run build
9:13:07 PM: ​
9:13:07 PM:   Resolved config
9:13:07 PM:   build:
9:13:07 PM:     command: npm run build
9:13:07 PM:     commandOrigin: ui
9:13:07 PM:     publish: /opt/build/repo/dist
9:13:07 PM:     publishOrigin: ui
9:13:08 PM: Caching artifacts
9:13:08 PM: Started saving node modules
9:13:08 PM: Finished saving node modules
9:13:08 PM: Started saving build plugins
9:13:08 PM: Finished saving build plugins
9:13:08 PM: Started saving pip cache
9:13:08 PM: Finished saving pip cache
9:13:08 PM: Started saving emacs cask dependencies
9:13:08 PM: Finished saving emacs cask dependencies
9:13:08 PM: Started saving maven dependencies
9:13:08 PM: Finished saving maven dependencies
9:13:08 PM: Started saving boot dependencies
9:13:08 PM: Finished saving boot dependencies
9:13:08 PM: Started saving rust rustup cache
9:13:08 PM: Finished saving rust rustup cache
9:13:08 PM: Started saving go dependencies
9:13:08 PM: Finished saving go dependencies
9:13:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:13:10 PM: Creating deploy upload records
9:13:11 PM: Failing build: Failed to build site
9:13:11 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
9:13:11 PM: Finished processing build request in 1m3.721552396s

Hi @Posoroko,

The error lies with the code and we cannot guess where exactly in it it’s coming from. You need to check where exactly you’re trying to use foo.request where foo could be any object. If it’s not you, one of your dependencies might be causing issues and you might have to use trial and error to figure out which one it is.

Hi! thanks for your answer!

I tried deleting the post, but couldn’t find how. I continued working on the code without deployin and realised this morning the it had finaly buit by itself on netlify after I pushed modifications to github. I have no clue what the bug was. :slight_smile: