cypress-io / cypress-realworld-app

A payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.
https://docs.cypress.io
MIT License
5.53k stars 2.23k forks source link

RWA fails to start on Windows 11 #1529

Closed MikeMcC399 closed 8 months ago

MikeMcC399 commented 8 months ago

The error is:

$ NODE_ENV=development nodemon --exec yarn tsnode --watch 'backend' backend/app.ts [start:api:watch] 'NODE_ENV' is not recognized as an internal or external command, [start:api:watch] operable program or batch file. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. [start:api:watch] error Command failed with exit code 1. [start:api:watch] yarn run start:api:watch exited with code 1

Steps to reproduce

Windows 11 Node.js 20.11.0

npm install yarn -g
git clone https://github.com/cypress-io/cypress-realworld-app
cd cypress-realworld-app
yarn
yarn dev

Logs

$ yarn dev
yarn run v1.22.19
$ yarn db:seed:dev
$ yarn predev:cognito:ci
$ yarn copy:mock:awsexports && yarn copy:mock:awsexportses5
$ ncp scripts/mock-aws-exports.js src/aws-exports.js
$ ncp scripts/mock-aws-exports-es5.js aws-exports-es5.js
$ ncp ./data/database-seed.json ./data/database.json
$ cross-env NODE_ENV=development concurrently yarn:start:react yarn:start:api:watch
$ vite
$ NODE_ENV=development nodemon --exec yarn tsnode --watch 'backend' backend/app.ts
[start:api:watch] 'NODE_ENV' is not recognized as an internal or external command,
[start:api:watch] operable program or batch file.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[start:api:watch] error Command failed with exit code 1.
[start:api:watch] yarn run start:api:watch exited with code 1
[start:react]
[start:react]   VITE v4.4.2  ready in 1246 ms
[start:react]
[start:react]   ➜  Local:   http://localhost:3000/
[start:react]   ➜  Network: use --host to expose

Workaround

git switch -c fix-windows
git revert 6fbb8f767e820b56b3dda8c5c97f0a6bbd35bc54 --no-edit
yarn

Confirm with

yarn dev

which should start like this:

$ yarn dev
yarn run v1.22.19
$ yarn db:seed:dev
$ yarn predev:cognito:ci
$ yarn copy:mock:awsexports && yarn copy:mock:awsexportses5
$ ncp scripts/mock-aws-exports.js src/aws-exports.js
$ ncp scripts/mock-aws-exports-es5.js aws-exports-es5.js
$ ncp ./data/database-seed.json ./data/database.json
$ cross-env NODE_ENV=development concurrently yarn:start:react yarn:start:api:watch
$ vite
$ nodemon --exec yarn tsnode --watch 'backend' backend/app.ts
[start:api:watch] [nodemon] 2.0.22
[start:api:watch] [nodemon] to restart at any time, enter `rs`
[start:api:watch] [nodemon] watching path(s): 'backend'
[start:api:watch] [nodemon] watching extensions: ts,json
[start:api:watch] [nodemon] starting `yarn tsnode backend/app.ts`
$ nyc --silent ts-node -P tsconfig.tsnode.json backend/app.ts
[start:react]
[start:react]   VITE v4.4.2  ready in 981 ms
[start:react]
[start:react]   ➜  Local:   http://localhost:3000/
[start:react]   ➜  Network: use --host to expose
[start:api:watch] Browserslist: caniuse-lite is outdated. Please run:
[start:api:watch]   npx update-browserslist-db@latest
[start:api:watch]   Why you should do it regularly: https://github.com/browserslist/update-db#readme
[start:api:watch] express-validator: sanitize(), sanitizeBody() and other sanitization-only middlewares have been deprecated.
[start:api:watch] Please use check(), body() and others instead, which must offer the same API, and more.
[start:api:watch] Backend server running at http://localhost:3001
MikeMcC399 commented 8 months ago
-    "start:api": "yarn tsnode --files backend/app.ts",
-    "start:api:watch": "nodemon --exec yarn tsnode --watch 'backend' backend/app.ts",
+    "start:api": "NODE_ENV=development yarn tsnode --files backend/app.ts",
+    "start:api:watch": "NODE_ENV=development nodemon --exec yarn tsnode --watch 'backend' backend/app.ts",

from

$ git diff d6f7f394..6fbb8f76 package.json
diff --git a/package.json b/package.json
index bf16ea8d..9f90838f 100644
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
     "@babel/plugin-proposal-private-property-in-object": "7.21.11",
     "@cypress/code-coverage": "^3.10.0-dev.1",
     "@cypress/instrument-cra": "1.4.0",
+    "@cypress/vite-dev-server": "^5.0.7",
     "@faker-js/faker": "6.1.2",
     "@percy/cli": "^1.27.4",
     "@percy/cypress": "3.1.2",
@@ -64,11 +65,10 @@
     "@types/connect-history-api-fallback": "1.3.5",
     "@types/cors": "2.8.12",
     "@types/dinero.js": "1.9.0",
-    "@types/express": "4.17.2",
-    "@types/express-paginate": "1.0.1",
+    "@types/express": "4.17.21",
+    "@types/express-paginate": "1.0.4",
     "@types/express-serve-static-core": "4.17.2",
-    "@types/express-session": "1.17.4",
-    "@types/faker": "5.5.9",
+    "@types/express-session": "1.18.0",
     "@types/http-proxy-middleware": "0.19.3",
     "@types/json-server": "0.14.4",
     "@types/jsonwebtoken": "8.5.8",
@@ -76,8 +76,8 @@
     "@types/lodash": "4.14.181",
     "@types/lowdb": "1.0.11",
     "@types/morgan": "1.9.3",
-    "@types/node": "14.18.13",
-    "@types/passport": "1.0.7",
+    "@types/node": "^20.11.25",
+    "@types/passport": "1.0.16",
     "@types/react": "^18.2.14",
     "@types/react-dom": "^18.2.6",
     "@types/react-infinite-calendar": "2.3.6",
@@ -123,7 +123,7 @@
     "nodemon": "2.0.22",
     "npm": "^9.8.0",
     "nyc": "15.1.0",
-    "passport": "0.6.0",
+    "passport": "0.5.0",
     "passport-local": "1.0.0",
     "patch-package": "^7.0.0",
     "prettier": "^3.0.0",
@@ -167,8 +167,8 @@
     "test:unit": "vitest",
     "test:unit:ci": "vitest --run",
     "test:component:ci": "yarn cypress:run:component",
-    "start:api": "yarn tsnode --files backend/app.ts",
-    "start:api:watch": "nodemon --exec yarn tsnode --watch 'backend' backend/app.ts",
+    "start:api": "NODE_ENV=development yarn tsnode --files backend/app.ts",
+    "start:api:watch": "NODE_ENV=development nodemon --exec yarn tsnode --watch 'backend' backend/app.ts",
     "start:react:proxy-server": "yarn tsnode scripts/testServer.ts",
     "prettier": "prettier --write \"**/**.{ts,js,tsx}\" \"*.{json,md,yml}\"",
     "tsnode": "nyc --silent ts-node -P tsconfig.tsnode.json",
jennifer-shehane commented 8 months ago

Open to a PR here. We don't run this on windows and don't intend to run tests on it.

MikeMcC399 commented 8 months ago

@jennifer-shehane

Open to a PR here. We don't run this on windows and don't intend to run tests on it.