Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'har-validator' #7880

Closed
SvenBudak opened this issue Nov 25, 2021 · 12 comments · Fixed by #7887
Closed

Error: Cannot find module 'har-validator' #7880

SvenBudak opened this issue Nov 25, 2021 · 12 comments · Fixed by #7887

Comments

@SvenBudak
Copy link

SvenBudak commented Nov 25, 2021

i migrated a project to angular 13 which was created before some weeks from scretch new with npx create-nx-workspace --preset=angular after this i was not able to npm i

npm ERR! code 1
npm ERR! path D:\mrm-store-kit\node_modules\cypress
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node index.js --exec install
npm ERR! node:internal/modules/cjs/loader:936
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module 'har-validator'
npm ERR! Require stack:
npm ERR! - D:\mrm-store-kit\node_modules\@cypress\request\lib\har.js
npm ERR! - D:\mrm-store-kit\node_modules\@cypress\request\request.js
npm ERR! - D:\mrm-store-kit\node_modules\@cypress\request\index.js
npm ERR! - D:\mrm-store-kit\node_modules\cypress\lib\tasks\download.js
npm ERR! - D:\mrm-store-kit\node_modules\cypress\lib\tasks\install.js
npm ERR! - D:\mrm-store-kit\node_modules\cypress\index.js
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
npm ERR!     at Object.<anonymous> (D:\mrm-store-kit\node_modules\@cypress\request\lib\har.js:5:16)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
npm ERR!     at Object.<anonymous> (D:\mrm-store-kit\node_modules\@cypress\request\request.js:23:11)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     'D:\\mrm-store-kit\\node_modules\\@cypress\\request\\lib\\har.js',
npm ERR!     'D:\\mrm-store-kit\\node_modules\\@cypress\\request\\request.js',
npm ERR!     'D:\\mrm-store-kit\\node_modules\\@cypress\\request\\index.js',
npm ERR!     'D:\\mrm-store-kit\\node_modules\\cypress\\lib\\tasks\\download.js',
npm ERR!     'D:\\mrm-store-kit\\node_modules\\cypress\\lib\\tasks\\install.js',
npm ERR!     'D:\\mrm-store-kit\\node_modules\\cypress\\index.js'
npm ERR!   ]
npm ERR! }

i also cant create anymore a new NX workspace

√ What to create in the new workspace · angular
√ Application name                    · sdf
√ Default stylesheet format           · scss
√ Use Nx Cloud? (It's free and doesn't require registration.) · No

>  NX  Nx is creating your workspace.

  To make sure the command works reliably in all environments, and that the preset is applied correctly,
  Nx will run "npm install" several times. Please wait.

√ Installing dependencies with npm
× Creating your workspace

>  NX   ERROR  Nx failed to create a workspace.

  Exit code: 1
  Log file: C:\Users\sven\AppData\Local\Temp\tmp-12540-J6SpNKoMcyJr\error.log

it seems that this project comes from cypress... so cypress is depricated?

@Crocsx
Copy link

Crocsx commented Nov 25, 2021

Same here all new projects with latest version are broken, looks like the problem is not from the repo tho, but coming from cypress. So probably need to change Cypress version once they patch it.

@Crocsx
Copy link

Crocsx commented Nov 25, 2021

cypress-io/cypress#19097
cypress-io/cypress#19102

as a temporary workaround if you need cypress.

you have to pin "@cypress/request" version, not cypress.

add

"@cypress/request": "2.88.7",
to your package.json and it should work.

@SvenBudak
Copy link
Author

Ok time to kick cypress out of my projects :D

@MattiaMalandrone
Copy link

Same problem with the latest version!

@ghost
Copy link

ghost commented Nov 25, 2021

was getting the same issue "Error: Cannot find module 'har-validator" while installing cypress for a new project. Resolved it by manually installing "har-validator" using "npm install har-validator"

@rosammav
Copy link

rosammav commented Nov 25, 2021

I was also getting the same error that runs the tests on GitHub actions.

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

Error: Cannot find module 'har-validator'
Require stack:

]
}
npm WARN cypress-ui-tests@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@8.7.0 postinstall: node index.js --exec install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress@8.7.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! /home/runner/.npm/_logs/2021-11-25T13_06_32_176Z-debug.log
Error: Process completed with exit code 1.

@krishan-QE
Copy link

npm install har-validator

This is worked for me.. Thanks..

my "yml" file

image: cypress/base:12.1.0

stages:

  • test

test:
stage: test
script:
- chmod +x cypress/
- npm install har-validator
- npm audit fix
- npm install cypress
- npm run runHeadless

@JoanEsquivel
Copy link

npm install har-validator

This works! Thanks

@SvenBudak
Copy link
Author

was getting the same issue "Error: Cannot find module 'har-validator" while installing cypress for a new project. Resolved it by manually installing "har-validator" using "npm install har-validator"

Guys.. please dont do this... Downgrade Cypress or wait for a fix...

@samartomar
Copy link

yes downgrade or install npm install requests it will add nothing to your project but things will work without issue.

@meeroslav
Copy link
Contributor

meeroslav commented Nov 25, 2021

A rollback fix has just been rolled out in version 2.88.9 an hour ago.

Just run:

  • rm -rf node_modules
  • yarn or npm i

And you should be fine. No need for any fixes on your side.

My temporary fix from today will be removed tomorrow morning. We only added it as this dependency was blocking the other PRs.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants