'Cannot find module error while running cypress test using saucectl

While trying to run cypress test from saucectl (saucelab) I am getting "Error: Cannot find module 'pdf-parse'". Not sure how to resolve this issue as my test works fine while running locally. Let me know if anyone has any solution for this.

index.js file path: \cypress\plugins\index.js pdf require detail: const pdfparser = require("pdf-parse");



Solution 1:[1]

This means that you have a dependency in your tests that is not installed on the Sauce Labs VM. Please check all dependencies you use in your tests and add them to you config yaml-file as described here

It would look something like this

npm:
  packages:
    pdf-parse: "1.1.1"

Solution 2:[2]

I think you missed to install the npm dependency,

npm i pdf-parse

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wswebcreation
Solution 2 Pali