Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Cypress configs are CommonJS under root "type": "module" and will fail to load

Đang mở Phù hợp với người mới
#2,224 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cypress, javascript, node.js
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu bằng cách đọc package.json ở thư mục gốc và cypress/plugins/index.js để xác nhận xung đột kiểu module được mô tả trong issue. Kiểm tra cách tệp plugin Cypress được tải, sau đó chọn một trong các cách sửa một dòng được đề xuất. Công việc hoàn tất khi plugin được tải dưới dạng hàm với cấu hình ESM ở thư mục gốc; hãy xác minh bằng lệnh Node được mô tả hoặc một kiểm tra Cypress phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Found while verifying #2221. Not a regression from that PR — it's pre-existing and currently latent, since no CI job runs Cypress.

The problem

Root package.json declares "type": "module" (re-added in f42f6fce, the ESM test-suite migration). That makes Node treat every .js under the repo root as ESM — including cypress/plugins/index.js, which is still CommonJS (module.exports = (on, config) => {...}).

cypress/support/index.js is comments-only today, so it's currently harmless, but it's in the same trap the moment anyone adds code to it.

Verified on development with Node v24.14.0:

$ node -e "console.log(typeof require('./cypress/plugins/index.js'))"
object

require() returns an empty namespace object instead of the exported function, so anything that loads the plugins file the way Cypress does will get a non-function — the same failure #2221 fixes for github-actions/pr-instructions/.

Suggested fix

Pick one, all are one-liners:

  • rename cypress/plugins/index.js → cypress/plugins/index.cjs (what #2221 does), or
  • add cypress/package.json containing { "type": "commonjs" } to scope the subtree back to CJS, or
  • relocate the file under a directory that already has a CJS package.json.

The cypress/package.json route is the more durable one, since it protects future files added under cypress/ automatically.

Not affected — checked already

  • shared/roles.js and shared/authorizationUtils.js also contain module.exports, but they're guarded with if (typeof module !== "undefined" && module.exports) and import each other as ESM, so they load correctly either way.
  • backend/ has its own package.json with "type": "module".
  • client/ has no type field, so its CJS configs (postcss.config.js, tailwind.config.js, setupProxy.js) are fine.

The only real breakage in the root tree is the Cypress plugins file.

Ngôn ngữ chính
JavaScript
Star
62
Fork
105
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của hackforla/VRMS

Tất cả issue của hackforla/VRMS

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.