question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when the command npx cypress open is executed

See original GitHub issue

Current behavior

I get this

error:C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:40
  invoke = (eventId, args = []) => {
         ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)


    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:7:24)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\require_async_child.js:12:13)
-------------

I already created 3 projects and the error is always the same.

Desired behavior

No errors!

Test code to reproduce

I get this

error:C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:40
  invoke = (eventId, args = []) => {
         ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)


    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:7:24)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\Alan\AppData\Local\Cypress\Cache\10.0.2\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\require_async_child.js:12:13)
-------------

I already created 3 projects and the error is always the same.

Cypress Version

10.0.2

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
edvitor13commented, Jun 3, 2022

This also happened to me, the way I found to solve it, provisionally, was to move all this “invoke” method into the constructor and add it to the “RunPlugins” object: “this.invoke”.

invoke = (eventId, args = []) => {
  const event = this.registeredEventsById[eventId]
  
  return event.handler(...args)
}

---->

constructor(...) {
...
  this.invoke = (eventId, args = []) => {
    const event = this.registeredEventsById[eventId]
    
    return event.handler(...args)
  }
}
1reaction
lmiller1990commented, Jun 9, 2022

@33Wil same question - what version of Node.js are on? Cypress requires v12. The error described here is the one you get when your version does not support class instance members:

v10.24.1
$ node -e 'class Foo { bar = () => {} }'                                                     
[eval]:1
class Foo { bar = () => {} }
                ^

SyntaxError: Unexpected token =
    at new Script (vm.js:83:7)
    at createScript (vm.js:277:10)
    at Object.runInThisContext (vm.js:329:10)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at evalScript (internal/bootstrap/node.js:590:27)
    at startup (internal/bootstrap/node.js:265:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

I don’t think this is a bug in Cypress, it’s the error you get when using a Node.js version outside the ones we support. Likely older versions technically worked with Cypress 9, but now Cypress 10 uses the class instance syntax, the fact you are running an unsupported version of Node.js is more clear.

If anyone is encountering this on Node v12, happy to look into it, but for now I’m going to close this as there’s no obvious actionable bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when running 'npx cypress open' · Issue #9608 - GitHub
Hi, looking at your error message it looks like you've mistyped the command with cypess instead of cypress. Try making sure your command...
Read more >
Cypress: When I try to run npx cypress open the window ...
I solve it by downgrading Cypress to version 10.0.3.
Read more >
Troubleshooting | Cypress Documentation
Run the npx patch-package cypress command. This command will create a new file patches/cypress+3.4. 1.
Read more >
Install Cypress - Tools QA
npx cypress open. Note : npx is available with npm > 5.2 version only. It is how the commands can run inside Visual...
Read more >
cypress-io/cypress - Gitter
Cypress failed to start. This is usually caused by a missing library or dependency. The error below should indicate which dependency is missing....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found