'buildkite error : The plugins file is missing or invalid. Cannot find module 'xlsx' when running cypress test . Runs fine on local

I am getting error when running the cypress test on buildkite as below:

Status: Downloaded newer image for cypress/included:6.1.0

[2022-01-31T10:32:13Z] Your pluginsFile is set to /e2e/cypress/plugins/index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js, .ts, or .coffee file.

Or you might have renamed the extension of your pluginsFile. If that's the case, restart the test runner.

Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.

Error: Cannot find module 'xlsx' Require stack:

  • /e2e/cypress/plugins/read-xlsx.js
  • /e2e/cypress/plugins/index.js

the same test runs fine on local on both browser and headless

"xlsx" is present in the package.json as both dependencies and dev dependencies.

code inside read-xlsx

const XLSX = require("xlsx");
const fs = require("fs");

const read = ({file, sheet}) => {
  const buf = fs.readFileSync(file);
  const workbook = XLSX.read(buf, { type: 'buffer' });
  const rows = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
  return rows
}
 
module.exports = {
  read
}

Someone please help



Solution 1:[1]

I had the same problem. But in my case, was an issue with case sensitive. I put 'XLSX' inside the require in the read-xlsx.js file.

My read-xlsx.js file became like this and worked:

const fs = require('fs')
const XLSX = require('xlsx')

Solution 2:[2]

I see several issues here. First, this can't work as you claim:

def user_right:
    t3.forward(5)
def user_left:
    t3.backward(5)

It would need to be:

def user_right():
    t3.forward(5)
def user_left():
    t3.backward(5)

Next, this won't work in turtle in standard Python:

sc.onkey(user_left,"left")
sc.onkey(user_right,"right")

These keys would have to be "Left" and "Right". Are you using a non-standard turtle implementation? (E.g. the one on repl.it) You show your two event handlers that work, but fail to show the two that don't which would be of more interest when trying to debug your code.

Finally, your missing a call to the screen's listen() method, so your keystrokes are ignored. Here's how I might implement the functionality your code is hinting at:

from turtle import Screen, Turtle

def user_right():
    turtle.forward(5)

def user_left():
    turtle.backward(5)

def user_up():
    turtle.sety(turtle.ycor() + 5)

def user_down():
    turtle.sety(turtle.ycor() - 5)

turtle = Turtle()
turtle.shape('turtle')

screen = Screen()

screen.onkey(user_left, 'Left')
screen.onkey(user_right, 'Right')
screen.onkey(user_up, 'Up')
screen.onkey(user_down, 'Down')

screen.listen()
screen.mainloop()

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
Solution 2 cdlane