cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.74k stars 3.16k forks source link

npm install --only=development crashes due to is-promise in dependency listr #7201

Closed pan-bubr closed 4 months ago

pan-bubr commented 4 years ago

Current behavior:

When I try to execute npm install --only=development command (for multi-stage build) installation crashes due to lack of runtime dependency minimist in cypress's postinstall stage.

It doesn't happen when it is installed alone, but I found some combinations of libraries that bring this bug to life. In this case it crashes with @nestjs/common.

stacktrace

> cypress@4.5.0 postinstall /node_modules/cypress
> node index.js --exec install

internal/modules/cjs/loader.js:960
  throw err;
  ^

Error: Cannot find module 'is-promise'
Require stack:
- /node_modules/listr/lib/task.js
- /node_modules/listr/index.js
- /node_modules/cypress/lib/tasks/install.js
- /node_modules/cypress/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/node_modules/listr/lib/task.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/node_modules/listr/index.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/node_modules/listr/lib/task.js',
    '/node_modules/listr/index.js',
    '/node_modules/cypress/lib/tasks/install.js',
    '/node_modules/cypress/index.js'
  ]
}

Desired behavior:

Installing cypress with npm install --only=development should not crash install build.

Test code to reproduce

Dockerfile

FROM node:12.13-stretch AS development

WORKDIR /usr/src/app

COPY package.json ./
RUN npm install --only=development

package.json

{
  "dependencies": {
    "@nestjs/common": "^6.8.3"
  },
  "devDependencies": {
    "cypress": "^4.1.0",
    "@nrwl/cypress": "9.2.3"
  }
}

Versions

Cypress: 4.5.0

jennifer-shehane commented 4 years ago

I'm not able to reproduce this. Try cleaning your node_modules or running npm prune.

jennifer-shehane commented 4 years ago

Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.

RomeroDiver commented 4 years ago

This is still very much happening :(

jennifer-shehane commented 4 years ago

Ok, yah I actually am able to reproduce this. I feel like this didn't reproduce last time I ran it.

Love how unhelpful this thread is :/ https://github.com/nodejs/help/issues/1846

Add the below to package.json and run npm install --only=development

{
  "dependencies": {
    "@nestjs/common": "^6.8.3"
  },
  "devDependencies": {
    "cypress": "4.10.0"
  }
}
npm install --only=development

> cypress@4.10.0 postinstall /Users/jennifer/Dev/cypress-transform-test/node_modules/cypress
> node index.js --exec install

internal/modules/cjs/loader.js:979
  throw err;
  ^

Error: Cannot find module 'is-promise'
Require stack:
- /Users/jennifer/Dev/cypress-transform-test/node_modules/listr/lib/task.js
- /Users/jennifer/Dev/cypress-transform-test/node_modules/listr/index.js
- /Users/jennifer/Dev/cypress-transform-test/node_modules/cypress/lib/tasks/install.js
- /Users/jennifer/Dev/cypress-transform-test/node_modules/cypress/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/jennifer/Dev/cypress-transform-test/node_modules/listr/lib/task.js:2:19)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/jennifer/Dev/cypress-transform-test/node_modules/listr/index.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/jennifer/Dev/cypress-transform-test/node_modules/listr/lib/task.js',
    '/Users/jennifer/Dev/cypress-transform-test/node_modules/listr/index.js',
    '/Users/jennifer/Dev/cypress-transform-test/node_modules/cypress/lib/tasks/install.js',
    '/Users/jennifer/Dev/cypress-transform-test/node_modules/cypress/index.js'
  ]
}
npm WARN @nestjs/common@6.11.11 requires a peer of reflect-metadata@^0.1.12 but none is installed. You must install peer dependencies yourself.
npm WARN @nrwl/cypress@9.2.3 requires a peer of @nrwl/workspace@9.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN @cypress/webpack-preprocessor@4.1.5 requires a peer of webpack@^4.18.1 but none is installed. You must install peer dependencies yourself.
npm WARN ts-loader@5.4.5 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN babel-loader@8.1.0 requires a peer of webpack@>=2 but none is installed. You must install peer dependencies yourself.
npm WARN cypress-transform-test No repository field.
npm WARN cypress-transform-test No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@4.10.0 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress@4.10.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jennifer/.npm/_logs/2020-07-08T07_19_41_110Z-debug.log
chyzwar commented 3 years ago

We have another issue with listr. It pull date-fns v1 that change what is hoisted in yarn moonorepo. Maybe cypress can consider switching to listr2 https://github.com/cenk1cenk2/listr2 ?

obergerdavid commented 3 years ago

I am also getting a similar error:

package.json

{
  ...
  "dependencies": {
    "@angular/animations": "^11.2.7",
    "@angular/cdk": "^11.2.6",
    "@angular/common": "^11.2.7",
    "@angular/compiler": "^11.2.7",
    "@angular/core": "^11.2.7",
    "@angular/flex-layout": "^11.0.0-beta.33",
    "@angular/forms": "^11.2.7",
    "@angular/localize": "^11.2.7",
    "@angular/material": "^11.2.6",
    "@angular/platform-browser": "^11.2.7",
    "@angular/platform-browser-dynamic": "^11.2.7",
    "@angular/router": "^11.2.7",
    "@nestjs/common": "^7.0.0",
    "@nestjs/config": "^0.6.3",
    "@nestjs/core": "^7.0.0",
    "@nestjs/jwt": "^7.2.0",
    "@nestjs/passport": "^7.1.5",
    "@nestjs/platform-express": "^7.0.0",
    "@nestjs/typeorm": "^7.1.5",
    "@ng-bootstrap/ng-bootstrap": "^9.1.0",
    "@ngrx/effects": "^11.0.1",
    "@ngrx/entity": "^11.0.1",
    "@ngrx/store": "^11.0.1",
    "@ngrx/store-devtools": "^11.0.1",
    "@nrwl/angular": "11.6.0",
    "@nrwl/schematics": "^8.12.11",
    "@types/bcrypt": "^3.0.1",
    "@types/express": "^4.17.11",
    "@types/hapi__joi": "^17.1.6",
    "@types/passport-local": "^1.0.33",
    "bcrypt": "^5.0.1",
    "bootstrap": "^4.6.0",
    "cookie-parser": "^1.4.5",
    "eslint-plugin-prefer-arrow": "^1.2.3",
    "hammerjs": "^2.0.8",
    "joi": "^17.4.0",
    "jquery": "^3.6.0",
    "passport": "^0.4.1",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "pg": "^8.5.1",
    "popper.js": "^1.16.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^6.6.7",
    "tslib": "^2.1.0",
    "typeorm": "^0.2.32",
    "zone.js": "^0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1102.6",
    "@angular-eslint/eslint-plugin": "~2.0.2",
    "@angular-eslint/eslint-plugin-template": "~2.0.2",
    "@angular-eslint/template-parser": "~2.0.2",
    "@angular/cli": "~11.2.6",
    "@angular/compiler-cli": "^11.2.7",
    "@angular/language-service": "^11.2.7",
    "@nestjs/schematics": "^7.0.0",
    "@nestjs/testing": "^7.0.0",
    "@ngrx/schematics": "^11.0.1",
    "@nrwl/cli": "11.6.0",
    "@nrwl/cypress": "11.6.0",
    "@nrwl/eslint-plugin-nx": "11.6.0",
    "@nrwl/jest": "11.6.0",
    "@nrwl/linter": "11.6.0",
    "@nrwl/nest": "^12.0.0",
    "@nrwl/node": "12.0.0",
    "@nrwl/tao": "11.6.0",
    "@nrwl/workspace": "11.6.0",
    "@types/jest": "26.0.22",
    "@types/node": "14.14.37",
    "@typescript-eslint/eslint-plugin": "4.20.0",
    "@typescript-eslint/parser": "4.20.0",
    "concurrently": "^6.0.2",
    "cypress": "^6.9.1",
    "dotenv": "8.2.0",
    "eslint": "7.23.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-cypress": "^2.11.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsdoc": "^32.3.0",
    "jest": "26.6.3",
    "jest-preset-angular": "8.4.0",
    "prettier": "^2.2.1",
    "ts-jest": "26.5.4",
    "ts-node": "~9.1.1",
    "typescript": "^4.1.5"
  }
}

Output of npm install --only=development

> cypress@6.9.1 postinstall /usr/src/app/node_modules/cypress
> node index.js --exec install

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'minimist'
Require stack:
- /usr/src/app/node_modules/cypress/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/src/app/node_modules/cypress/index.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/src/app/node_modules/cypress/index.js' ]
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/@nrwl/node/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@6.9.1 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cypress@6.9.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-04-19T09_53_32_591Z-debug.log
jennifer-shehane commented 3 years ago

We would be open to any pull requests to replace listr with https://listr2.kilic.dev/ since listr is no longer maintained.

mesqueeb commented 3 years ago

I'm getting the same issue on v7.2.0

image

require stack points to

/node_modules/cypress/index.js
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:769:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:997:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:92:18)
npm ERR!     at Object.<anonymous> (/node_modules/cypress/index.js:3:18)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1108:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:973:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:813:14)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
npm ERR!   code: 'MODULE_NOT_FOUND',
beharefe commented 2 years ago

Still getting this error on 8.6.0, any update or solution?

AakrritiJain commented 2 years ago

Facing similar issue, any updates? Error: Cannot find module 'har-validator' Coming for cypress@8.2.0

Luminisc commented 2 years ago

Cypress@9.0.0 I got similar issue, but with in some dependency (Cannot find module './promise') image The issue is that in folder '\node_modules\bluebird\js\release' there was only 5-7 files, and no 'promise.js'. And even deleting and 'npm installing' not fixed issue. But, I found out that root cause actually is long path of project, and then I moved it to drive root (ex. C:/projects/my-proj), and ran 'npm install' - everything installed correctly and works perfectly. Maybe this will help somebody.

EMCP commented 2 years ago

Seeing this behavior in a project .. this runs in a CICD so.. unclear how to use @Luminisc 's advice :\

$ node --version
v14.19.1
$ npm --version
6.14.16
$ npm install --only=dev
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
> @parcel/watcher@2.0.0-alpha.11 install /builds/project/node_modules/@parcel/watcher
> node-gyp-build
> core-js-pure@3.13.0 postinstall /builds/project/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/cli@12.0.0 postinstall /builds/project/node_modules/@angular/cli
> node ./bin/postinstall/script.js
> cypress@6.9.1 postinstall /builds/project/node_modules/cypress
> node index.js --exec install
internal/modules/cjs/loader.js:905
  throw err;
  ^
Error: Cannot find module 'minimist'
Require stack:
- /builds/project/node_modules/cypress/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/builds/project/node_modules/cypress/index.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/builds/JRGEMCP/MAHRIO/mahrio-two-one/node_modules/cypress/index.js'
  ]
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@6.9.1 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cypress@6.9.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-04-01T17_44_30_672Z-debug.log
molteninjabob commented 2 years ago

I don't know if any headway has been made on this, but I'm running into this issue in Cypress 10.7, but with another package. This is also occurring for me in a CICD pipeline when trying to build our application in a container:

#12 18.14 npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
#12 22.92 npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
#12 22.99 npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
#12 43.14 npm notice
#12 43.14 npm notice New minor version of npm available! 8.15.0 -> 8.19.1
#12 43.14 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.1>
#12 43.14 npm notice Run `npm install -g npm@8.19.1` to update!
#12 43.14 npm notice
#12 43.15 npm ERR! code 1
#12 43.15 npm ERR! path /app/web.legacy/node_modules/cypress
#12 43.15 npm ERR! command failed
#12 43.15 npm ERR! command sh /tmp/postinstall-63bc7bdb.sh
#12 43.15 npm ERR! node:internal/modules/cjs/loader:959
#12 43.15 npm ERR!   throw err;
#12 43.15 npm ERR!   ^
#12 43.15 npm ERR!
#12 43.15 npm ERR! Error: Cannot find module 'arch'
#12 43.15 npm ERR! Require stack:
#12 43.15 npm ERR! - /app/web.legacy/node_modules/cypress/lib/util.js
#12 43.15 npm ERR! - /app/web.legacy/node_modules/cypress/index.js
#12 43.15 npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
#12 43.15 npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:804:27)
#12 43.15 npm ERR!     at Module.require (node:internal/modules/cjs/loader:1028:19)
#12 43.15 npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
#12 43.15 npm ERR!     at Object.<anonymous> (/app/web.legacy/node_modules/cypress/lib/util.js:5:14)
#12 43.15 npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1126:14)
#12 43.15 npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
#12 43.15 npm ERR!     at Module.load (node:internal/modules/cjs/loader:1004:32)
#12 43.15 npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:839:12)
#12 43.15 npm ERR!     at Module.require (node:internal/modules/cjs/loader:1028:19) {
#12 43.15 npm ERR!   code: 'MODULE_NOT_FOUND',
#12 43.15 npm ERR!   requireStack: [
#12 43.15 npm ERR!     '/app/web.legacy/node_modules/cypress/lib/util.js',
#12 43.15 npm ERR!     '/app/web.legacy/node_modules/cypress/index.js'
#12 43.15 npm ERR!   ]
#12 43.15 npm ERR! }
#12 43.16
#12 43.16 npm ERR! A complete log of this run can be found in:
#12 43.16 npm ERR!     /root/.npm/_logs/2022-09-13T21_15_25_379Z-debug-0.log
------
executor failed running [/bin/sh -c npm ci --omit=dev]: exit code: 1
jennifer-shehane commented 4 months ago

I'm not encountering this issue in the latest Cypress.