abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
498 stars 89 forks source link

[Bug] global install using Node.js through nvm #241

Open pcouas opened 3 years ago

pcouas commented 3 years ago

Hi

I have tried an npm install -g cypress-file-upload because cypress is installed on global, but module is not found

Regards

abramenal commented 3 years ago

Hi @pcouas which module isn't found? Can you please share more details/stacktrace/etc?

I don't think you need to install this package globally in any case

MuckT commented 3 years ago

An update on this. I'd like to install cypress-file-upload globally if possible. If I do a global install of cypress I have no problem running it on the build machine. If I use cypress-file-upload all the cypress test fails including those that do not directly use cypress-file-upload.

2021-03-26T02:12:22.6848524Z Oops...we found an error preparing this test file:
2021-03-26T02:12:22.6849715Z 
2021-03-26T02:12:22.6864253Z   src\support\index.js
2021-03-26T02:12:22.6864944Z 
2021-03-26T02:12:22.6886618Z The error was:
2021-03-26T02:12:22.6887293Z 
2021-03-26T02:12:22.6895665Z Error: Webpack Compilation Error
2021-03-26T02:12:22.6915342Z ./src/support/index.js
2021-03-26T02:12:22.6922401Z Module not found: Error: Can't resolve 'cypress-file-upload' in 'C:\agent1\_work\r3\a\tests\src\support'
2021-03-26T02:12:22.6927925Z resolve 'cypress-file-upload' in 'C:\agent1\_work\r3\a\tests\src\support'
2021-03-26T02:12:22.6937492Z   Parsed request is a module
2021-03-26T02:12:22.6940965Z   No description file found
2021-03-26T02:12:22.6946679Z   Looked for and couldn't find the file at the following paths: or is not a directory
2021-03-26T02:12:22.6953116Z [C:\agent1\_work\r3\a\tests\src\support\package.json]
2021-03-26T02:12:22.6964369Z [C:\agent1\_work\r3\a\tests\src\support\node_modules]
2021-03-26T02:12:22.6969397Z [C:\agent1\_work\r3\a\tests\src\node_modules]
2021-03-26T02:12:22.6979305Z [C:\agent1\_work\r3\a\tests\node_modules]
2021-03-26T02:12:22.6985202Z [C:\agent1\_work\r3\a\node_modules]
2021-03-26T02:12:22.6994513Z [C:\agent1\_work\r3\node_modules]
2021-03-26T02:12:22.6999131Z [C:\agent1\_work\node_modules]
2021-03-26T02:12:22.7011883Z [C:\agent1\node_modules]
2021-03-26T02:12:22.7016453Z [C:\node_modules]
2021-03-26T02:12:22.7027100Z  @ ./src/support/index.js 5:0-30
2021-03-26T02:12:22.7027779Z 
2021-03-26T02:12:22.7071895Z This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
2021-03-26T02:12:22.7076715Z 
2021-03-26T02:12:22.7086154Z - A missing file or dependency
2021-03-26T02:12:22.7091972Z - A syntax error in the file or one of its dependencies
2021-03-26T02:12:22.7096363Z 
2021-03-26T02:12:22.7103887Z Fix the error in your code and re-run your tests.
MuckT commented 3 years ago

@abramenal was an issue with nvm. After uninstalling and using node directly I was able to do a global install and move the installed node_modules folder to C:\node_modules. Probably not the best solution, but the reduction in e2e test execution time was worth it.

abramenal commented 3 years ago

Thanks for this info @MuckT. Really good to know that ppl have such use case, and that it's not working properly with nvm. I'll leave it open then, but don't expect it to be fixed really soon

blindahl commented 2 years ago

From what I can see this issue is the same as we have. If not, let me know and I'll file a new issue instead.

I have this issue as well since we're running cypress folder in folder parallell to where webapp/node_modules folder is. File structure is like this:

src\main\webapp\package.json
src\main\webapp\node_modules
src\test\cypress\

So when trying to run cypress it complains that:

Module not found: Error: Can't resolve 'cypress-file-upload' in '...\src\test\cypress\support'
resolve 'cypress-file-upload' in '...\src\test\cypress\support'
  Parsed request is a module
  No description file found
  Looked for and couldn't find the file at the following paths:

since it doesn't go into src\main\webapp folder to look for cypress-files\upload. Any idea how to solve this?