Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Docker image not compatible with ESM, failing with "configFile is invalid ... Unexpected identifier 'assert'" #1053

Closed
philly-vanilly opened this issue Apr 26, 2024 · 8 comments

Comments

@philly-vanilly
Copy link

philly-vanilly commented Apr 26, 2024

Current behavior

Since yesterday I was getting this error despite not having updated anything in my code:

Your configFile is invalid: /opt/atlassian/pipelines/agent/build/apps/app-e2e/configs/cypress.config.dev.ts
It threw an error when required, check the stack trace below:
SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
    at callTranslator (node:internal/modules/esm/loader:416:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)

app-e2e package in my npm monorepo is using ESM and ESM might have problems importing jsons, eg

import foo from './foo.json' assert { type: 'json' };

however, in our own code there were no such imports. I have pinned the version used in bitbucket pipelines to the previous one:

image: cypress/browsers:node-20.12.2-chrome-124.0.6367.60-1-ff-125.0.2-edge-124.0.2478.51-1

and it did the trick. Please fix your docker images and make them ESM compatible again.

Desired behavior

No response

Test code to reproduce

package.json:

"type": "module",
"scripts": {
  "cypress:run": "cypress run --e2e --config-file=configs/cypress.config.dev.ts"
}

Cypress Version

cypress-13.6.6.tgz

Node version

20.11.0

Operating System

linux, specifics you should know better whatever is used in cypress/browser docker image

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

@philly-vanilly What was the docker-image you were using that was causing the issue?

@philly-vanilly
Copy link
Author

@philly-vanilly What was the docker-image you were using that was causing the issue?

http://docker.io/cypress/browsers@sha256:44efcf6a4caba0a565a9677aa2ed2f98b24c33f25132792f56e47a3c5751563d

@jennifer-shehane
Copy link
Member

@philly-vanilly This link 404s for me. Can you point to the tag? https://hub.docker.com/r/cypress/browsers/tags

@teamcore-admin
Copy link

I have exactly the same problem with node:latest
sha256:cbd62dc7ba7e50d01520f2c0a8d9853ec872187fa806ed61d0f87081c220386d

@kgodsmark
Copy link

kgodsmark commented May 7, 2024

Same for me with node:latest
sha256:64c46a664eccedec63941dab4027c178a36debe08a232d4f9d7da5aca91cff3d

I set it to node:21 and CI has run OK.

@philly-vanilly
Copy link
Author

@philly-vanilly This link 404s for me. Can you point to the tag? https://hub.docker.com/r/cypress/browsers/tags

It was the latest tag on April 26 when I created this issue, so I assume it was resolved to node-22.0.0-chrome-124.0.6367.60-1-ff-125.0.2-edge-124.0.2478.51-1

@jennifer-shehane jennifer-shehane transferred this issue from cypress-io/cypress May 16, 2024
@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented May 17, 2024

@philly-vanilly

I noticed that JSON modules import under ESM is experimental and therefore unstable https://nodejs.org/docs/latest-v20.x/api/documentation.html#stability-index.

It would be good to have a repo which demonstrates your issue, so it can be reproduced and analyzed more easily.

@MikeMcC399
Copy link
Collaborator

@philly-vanilly

See https://nodejs.org/docs/latest-v20.x/api/esm.html#import-attributes. You will need to change your code. This isn't a bug in the Cypress Docker images.

image

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants