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.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
obergerdavidcommented, Apr 19, 2021

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
1reaction
Luminisccommented, Jan 20, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm install should recursively check/install dependencies #1341
After that I just had to temporarily move the dependencies from the node_modules directory and reinstall, then move them back and it worked...
Read more >
npm install won't install devDependencies - Stack Overflow
If I run npm install --dev devDependencies are installed. I don't understand why npm install doesn't install devDependencies too, but installs only dependencies...
Read more >
How to clean up node modules? - Mario Kandut
Manually remove and reinstall. You could remove your node_modules/ folder and then reinstall the dependencies from package.json. Remove all your ...
Read more >
Adding dependencies to a package.json file - npm Docs
To add dependencies and devDependencies to a package.json file from the command line, you can install them in the root directory of your...
Read more >
Node.js 15 Is Out! What Does It Mean for You? - Maxim Orlov
(node:1309) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch ...
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