bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
54 stars 9 forks source link

cypress-ntlm-auth can not resolve cypress (cypress-ntlm-auth requires Cypress to be installed) #240

Closed SarunasMaro closed 6 months ago

SarunasMaro commented 10 months ago

Hello,

I have "cypress": "12.9.0" and "cypress-ntlm-auth": "^4.1.2" versions installed on my machine and when I run commands yarn run cypress-ntlm run or yarn run cypress-ntlm open, I get the following error: "cypress-ntlm-auth requires Cypress to be installed". Looking at the source code in src/startup/cypress.loader.js and src/startup/startup.ts it seems that cypress-ntlm-auth can not resolve cypress. Our project has enjoyed Cypress in combination with cypress-ntlm-auth in the past a lot. Could you please help?

Machine: Macbook Pro M1 chip OS: MacOS Ventura 13.5.1 Package manager: Yarn Package installation strategy: Yarn Plug'n'Play

bjowes commented 10 months ago

I have very limited experience with yarn but in principle it should work. When the plugin can’t find cypress, the issue is usually that cypress was installed globally but the plugin was installed locally (in project folder). Verify that both cypress and plugin are installed locally.

/Björn W

Skickat från min iPhone

tors 7 sep. 2023 kl. 15:16 skrev SarunasMaro @.***>:

Hello,

I have "cypress": "12.9.0" and "cypress-ntlm-auth": "^4.1.2" versions installed on my machine and when I run commands yarn run cypress-ntlm run or yarn run cypress-ntlm open, I get the following error: "cypress-ntlm-auth requires Cypress to be installed". Looking at the source code in src/startup/cypress.loader.js and src/startup/startup.ts it seems that cypress-ntlm-auth can not resolve cypress. Our project has enjoyed Cypress in combination with cypress-ntlm-auth in the past a lot. Could you please help?

Machine: Macbook Pro M1 chip OS: MacOS Ventura 13.5.1 Package manager: Yarn Package installation strategy: Yarn Plug'n'Play

— Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/240, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3FYKKAAGQ4PBQJ7P5DXZHCJBANCNFSM6AAAAAA4O4PVII . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SarunasMaro commented 10 months ago

I can confirm that Cypress and cypress-ntlm-auth are both locally installed devDependencies. The testing module is the only place in the project that they are installed in.

bjowes commented 10 months ago

After a bit of read-up it seems to me that the Plug'n'Play strategy changes quite a bit how installed packages are stored. Most likely this results in that NodeJS cannot detect that cypress is actually installed.

First, try avoiding the Plug'n'Play strategy, at least for the cypress part of your project.

If you really want to make that work too, try setting a path to where cypress can be found as a second argument to the require.resolve('cypress') in startup/cypress.loader.js in the plugin. Likely some similar workaround would then be needed with the resolve('cypress) call in the same file. Once you get that working, let me know what you did and I will consider adding some additional environment variable to pass additional resolve paths.

SarunasMaro commented 10 months ago

Well, I can't access these files as they are zipped. Could you maybe add that line of code in the next release?

bjowes commented 10 months ago

Not sure what you mean, if the files you need to access are zipped, just unzip them. The problem here is that I don't know what path to add, this would need some trying out and may even be project specific. If you provide a repo here I can reproduce your issue I can help in more detail, but with the limited info I have there is not much I can do. As stated, the simple solution is to avoid using the Plug'n'Play strategy in yarn.