Skip to content

ERROR: Could not resolve "util" in version 1.33.0 and up caused by unused import #1004

@JessePomerenk

Description

@JessePomerenk

Version 1.33 and up attempt to import a module "util" in the folder "browserstack-cypress-cli/testObervability/cypress/index.js"
The browserstack-cypress-cli module also does not include it in their dependencies, relying on another node module to have it as a dependency instead.

Looking through the entire "browserstack-cypress-cli/testObervability/cypress/index.js" file, it looks like "util" is only assigned to a constant and never used anywhere in the module.

Either add util as a dependency for browserstack-cypress-cli or remove "util" in this file.

The error I am seeing is this ( I have removed any personal information and replaced it with "██"):

"This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
Oops...we found an error preparing this test file:
  > ██\somefile.feature

The error was :
Error: Build failed with 1 error:
node_modules/browserstack-cypress-cli/bin/testObservability/cypress/index.js:5:21: ERROR: Could not resolve "util"
    at failureErrorWithLog (██\node_modules\esbuild\lib\main.js:1467:15)
    at ██\node_modules\esbuild\lib\main.js:926:25
    at runOnEndCallbacks (██\node_modules\esbuild\lib\main.js:1307:45)
    at buildResponseToResult (██\node_modules\esbuild\lib\main.js:924:7)
    at ██\node_modules\esbuild\lib\main.js:951:16
    at responseCallbacks.<computed> (██\node_modules\esbuild\lib\main.js:603:9)
    at handleIncomingPacket ██\node_modules\esbuild\lib\main.js:658:12)
    at Socket.readFromStdout ██\node_modules\esbuild\lib\main.js:581:7)
    at Socket.emit (node:events:524:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)"

In my current setup we are running [email protected] which has removed util as a dependency which may have caused a breaking change in [email protected]+

https://docs.cypress.io/app/references/changelog#15-0-0
"In order to better align with best practices, @cypress/webpack-batteries-included-preprocessor no longer includes certain browser built-ins that were automatically provided by Webpack 4. The removed built-ins are assert, constants, crypto, domain, events, http, https, punycode, querystring, string_decoder, sys, timers, tty, url, util, vm, and zlib. However, we know that certain built-ins are popular, given that many users have files that are shared between their Cypress tests and node context. Because of this, @cypress/webpack-batteries-included-preprocessor will ship with built-in support for buffer, path, process, os, and stream. If there is a built-in that isn't supported by default and you need to add support, please refer to the Webpack resolve.fallback documentation and the @cypress/webpack-batteries-included-preprocessor README. Addresses #31039."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions