Closed vectorhacker closed 2 years ago
it looks like some of your packages are out of sync
"@nrwl/jest": "13.9.7",
"@nrwl/linter": "13.9.7",
"@nrwl/react": "^13.9.7",
"@nrwl/web": "13.9.7",
vs 13.10.0
npx create-nx-workspace --preset=apps
npm i -D @nrwl/cypress @nrwl/react
npx nx g @nrwl/react:app r-fe --e2eTestRunner=none
✔ Which stylesheet format would you like to use? · css
✔ Would you like to add React Router to this application? (y/N) · true
UPDATE nx.json
CREATE jest.config.js
CREATE jest.preset.js
UPDATE package.json
UPDATE .vscode/extensions.json
CREATE babel.config.json
CREATE apps/r-fe/.babelrc
CREATE apps/r-fe/.browserslistrc
CREATE apps/r-fe/src/app/app.spec.tsx
CREATE apps/r-fe/src/app/nx-welcome.tsx
CREATE apps/r-fe/src/assets/.gitkeep
CREATE apps/r-fe/src/environments/environment.prod.ts
CREATE apps/r-fe/src/environments/environment.ts
CREATE apps/r-fe/src/favicon.ico
CREATE apps/r-fe/src/index.html
CREATE apps/r-fe/src/main.tsx
CREATE apps/r-fe/src/polyfills.ts
CREATE apps/r-fe/tsconfig.app.json
CREATE apps/r-fe/tsconfig.json
CREATE apps/r-fe/src/app/app.module.css
CREATE apps/r-fe/src/app/app.tsx
CREATE apps/r-fe/src/styles.css
CREATE apps/r-fe/project.json
UPDATE workspace.json
CREATE .eslintrc.json
CREATE apps/r-fe/.eslintrc.json
CREATE apps/r-fe/jest.config.js
CREATE apps/r-fe/tsconfig.spec.json
npx nx g @nrwl/cypress:cypress-project --name=r-fe-e2e --project=r-fe
CREATE apps/r-fe-e2e/cypress.json
CREATE apps/r-fe-e2e/src/fixtures/example.json
CREATE apps/r-fe-e2e/src/integration/app.spec.ts
CREATE apps/r-fe-e2e/src/support/app.po.ts
CREATE apps/r-fe-e2e/src/support/commands.ts
CREATE apps/r-fe-e2e/src/support/index.ts
CREATE apps/r-fe-e2e/tsconfig.json
CREATE apps/r-fe-e2e/project.json
UPDATE workspace.json
CREATE apps/r-fe-e2e/.eslintrc.json
UPDATE package.json
I've updated my dependencies to the following:
"@nrwl/cli": "^13.10.1",
"@nrwl/cypress": "^13.10.1",
"@nrwl/eslint-plugin-nx": "13.10.1",
"@nrwl/jest": "13.10.1",
"@nrwl/linter": "13.10.1",
"@nrwl/react": "^13.10.1",
"@nrwl/web": "13.10.1",
"@nrwl/workspace": "13.10.1",
"nx": "13.10.1"
I'm now getting this error message when running yarn nx g @nrwl/cypress:cypress-project --name=<e2e-name> --project=<project>
:
Cannot read properties of undefined (reading 'serve')
@vectorhacker can you provide the full stack trace?
@barbados-clemens how do I provide that? That's all the output I get.
@vectorhacker you can use the --verbose
flag with nx
yarn nx g @nrwl/cypress:cypress-project --name=<e2e-name> --project=<project> --verbose
oops looks like you're running @nrwl/nrwl
instead of @nrwl/cypress
@barbados-clemens yeah haha I just noticed. Sorry. Here's the real one.
yarn run v1.22.18
$ /Users/<user>/dev/workspace/<repo>/node_modules/.bin/nx g @nrwl/cypress:cypress-project --name=<project>-e2e --project=<project> --verbose
TypeError: Cannot read properties of undefined (reading 'serve')
at addProject (/Users/<user>/dev/workspace/<repo>/node_modules/@nrwl/cypress/src/generators/cypress-project/cypress-project.js:52:49)
at /Users/<user>/dev/workspace/<repo>/node_modules/@nrwl/cypress/src/generators/cypress-project/cypress-project.js:166:9
at Generator.next (<anonymous>)
at /Users/<user>/dev/workspace/<repo>/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/<user>/dev/workspace/<repo>/node_modules/tslib/tslib.js:113:16)
at cypressProjectGenerator (/Users/<user>/dev/workspace/<repo>/node_modules/@nrwl/cypress/src/generators/cypress-project/cypress-project.js:163:20)
at Object.<anonymous> (/Users/<user>/dev/workspace/<repo>/node_modules/nx/src/command-line/generate.js:128:36)
at Generator.next (<anonymous>)
at fulfilled (/Users/<user>/dev/workspace/<repo>/node_modules/tslib/tslib.js:114:62)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
does the --project
you're passing to the cypress-project generator have a 'serve' target defined it the project.json?
the cypress-project generator adds the serve target to the e2e project devServerTarget
executor options.
const devServerTarget =
project.targets.serve && project.targets.serve.defaultConfiguration
? `${options.project}:serve:${project.targets.serve.defaultConfiguration}`
: `${options.project}:serve`;
(we should probably null check this and display an error just in case)
The project doesn't have any targets cus I followed the migration guide for CRA apps to an nx workspace and it suggests to remove those targets. Do I need to add a serve target?
So, I just added a serve
target that uses therun-script
executor and it works now.
"targets": {
"serve": {
"executor":"@nrwl/workspace:run-script",
"options": {
"script": "serve"
}
}
}
typically the cypress project generator is called via other application generators which will always scaffold out a serve target. but in the case of a manual target then you'll need to either pass in the baseUrl or a project with a serve target. in this case we aren't null checking the project to make sure it has a serve target leading to the error.
I'll update the cypress-project to null check the the project targets and print out an error message if one isn't found so you don't have this non discript error.
Thanks for finding the bug for us 😄
I'll leave this issue open to reference in the PR to make sure we give people better error with unexpected projects 👍
That's great! Glad I could be of help.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Error generating cypress project. Getting error related to not being able to find the logger.
Expected Behavior
Be able to geenrate a cypress e2e project. This is the first time I've run this command.
Steps to Reproduce
Install
@nrwl/cypress
yarn add --dev @nrwl/cypress
yarn nx generate @nrwl/cypress:cypress-project <project>-e2e --project=<project>
package.json:
Failure Logs
Environment