I was trying to setup and run nx tests for an established nx.dev angular application.
When I run nx e2e app-name-e2e
I get the error:
Cannot find module 'cypress/package.json'
Require stack:
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\cypress\src\utils\cypress-version.js
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\cypress\src\executors\cypress\cypress.impl.js
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\tao\src\shared\workspace.js
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\tao\src\commands\run.js
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\tao\index.js
- C:\repos\MyConnect2\src\Frontend\myconnect2\node_modules\@nrwl\cli\lib\run-cli.js
e2e tests were never used on this app, so configuration errors are not excluded (as the app had a few upgrades along the way, and e2e config might not have been maintained correctly).
This is running with angular v11.2 (and nx v 11.2), configured with default cypress for this nx.dev version
Found it... Thank you Pali for the comment
As the error states, the module cypress/package.json
is missing, that means the package "cypress" is missing.
Someone removed it along the way in this project as it takes a while to install...
The package "@nrwl/cypress" (nx.dev's cypress module) does not have a nominated dependency on the "cypress" package (but clearly has an implicit one).
I added the "cypress" package to the package.json file and installed it, and the problem no longer happens