Using Yarn to install Cypress fails - cypress

I tried installing Cypress via Yarn as the directions specify and am getting the following error.
I also notice not all the usual cypress folders were created.
What am I doing wrong here?
Given
yarn add cypress --dev
yarn run cypress open
Actual
Error
Expect
Cypress to run and have some basic examples

First install the yarn package globally by running npm install -g yarn and restart your terminal.
After you can try with this command:
yarn add cypress

Related

Cypress won't start, blank screen. Mac m1

I recently started getting this error where cypress only shows a blank screen and I can't seem to figure it out yet.
I've tried:
removing/reinstalling node_modules
running yarn
My cypress version in package.json:
"cypress": "^10.3.0",
When I run yarn cypress I get this message, and cypress opens with a blank screen:
objc[35990]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x222c25b50) and /Users/[username]/Library/Caches/Cypress/10.3.0/Cypress.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x10923d3c8). One of the two will be used. Which one is undefined.
I was able to get it running again, after clearing cypress cache.
npm uninstall -g cypress
npm i -g cypress#10.9
yarn cypress cache clear
yarn install
run with yarn cypress
https://docs.cypress.io/guides/references/troubleshooting#Clear-Cypress-cache

Cypress not openeing the Test runner on execution of command node_modules/.bin/cypress open

On execution of command node_modules/.bin/cypress open it gives below error-
I have installed cypress using npm package only
npm -i init
npm install cypress --save-dev
When I checked the Cache folder - C:\Users\usename\AppData\Local\Cypress\Cache\10.6.0\Cypress
Cypress.exe file is present, but not open when command executed (node_modules/.bin/cypress open)
Cypress version installed is 10.6.0
Error-
It looks like you are running the Cypress binary directly.
This is not the recommended approach, and Cypress may not work correctly.
Please install the cypress NPM package and follow the instructions here:
https://on.cypress.io/installing-cypress
use: "npx cypress open" command

Error while installing Cypress: Cypress cannot run because this binary file does not have executable permissions here:

Getting an error while installing Cypress.io. I followed the steps in the documentation and still getting the following error:
Cypress cannot run because this binary file does not have executable permissions here:
/Library/Caches/Cypress/6.8.0/Cypress.app/Contents/MacOS/Cypress
Reasons this may happen:
- node was installed as 'root' or with 'sudo'
- the cypress npm package as 'root' or with 'sudo'
Please check that you have the appropriate user permissions.
You can also try clearing the cache with 'cypress cache clear' and reinstalling.
The folder structure is app/e2e/, and basically right now only contains the yarn.lock & package.json.
Commands I ran were:
yarn init
yarn add cypress
yarn run cypress open
then tried:
sudo yarn add cypress
yarn run cypress open
still didn't work, so then I tried:
cypress cache clear
which still didn't work...
After following a few threads here on SO and some on the cypress repo, here's what helped me, and I hope it helps someone else.
In my case, I deleted the existing e2e folder(probably not needed) and then made a new e2e folder inside my app and then ran the following:
yarn init
yarn add cypress
yarn run cypress install // this was the key
yarn run cypress open
Now I get all the base files that come with a fresh install of cypress.

yarn berry run how to run installed packages

I see with yarn berry I get the plug'n'play feature instead of node_modules/
I couldn't find anything to suggest it supports running from installed packages.
For example with npm a workflow might be to run the installed version of webpack:
$ npm install --save-dev webpack
$ node node_modules/webpack/bin/webpack ...
A globally installed webpack might not be the same version. Worse yet, during Docker deployment, I get what's installed locally, the only node and npm are available globally. I thought I can do a preinstall script that does npm install -g yarn; yarn set version berry but then I'm not sure how to do webpack, jest, babel, etc, and the thought that I should have to install them all globally during the same preinstall hackaround seems like several steps backwards.
Is there some way to run from locally-installed packages that I'm missing?
I saw this possibly related question - Yarn Berry - Run a Node Script Directly
But the answer there seems a bit off the point - I'm not running any js, I'm trying to type in a package.json script, i.e. something that can run from the shell.
Why not just use yarn run <bin> (or simply yarn <bin>)? If you are in a repository set to use yarn berry, that will run any package bin file.
yarn node <file> will run any .js file with Plug n' Play set up. No need to install those dependencies globally, except for maybe yarn classic.
I was trying to do yarn some-bin and kept getting:
Couldn't find a script named "some-bin".
I eventually figured out it was because the package that provides some-bin is installed inside a workspace and not at the root of my project. So instead I had to run:
yarn workspace my-workspace some-bin
And that worked.

How to install all the dependency package in yarn?

First, I'm new to React. I'm trying to use Google's Material-UI for my React project. In this tutorial, it says run npm install, but I heard using yarn and npm together in the same project because it might bring about some confusion between those two later. So, I'm trying to stick to yarn only.
npm install seems to install all the dependency package for the thing that I wanna use, but how can I do that in yarn? I tried yarn add, but it didn't work. How can I do that?
EDIT
Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?
You should just be able to run yarn ("Running yarn with no command will run yarn install, passing through any provided flags." So just a simple yarn is what you'd want now, this answer previously suggested yarn install)
Here is a comparison table of most/all the commands you'd likely encounter
Edit Sept 2020: The newer versions of npm have greatly improved and caught up to yarn, so I currently have no clue what possible benefits yarn offers anymore, I'm 100% npm for the last year or so
The equivalent of $ npm install is just $ yarn (without arguments) to install all dependencies from package.json.
Also, just to clarify your query -
Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?
Doesn't matter whether you use yarn or npm, there will always be a package.json.
And no, there won't be a problem when using yarn later.
You get package-lock.json when using npm, and yarn.lock file when using yarn.
It's not recommended to use both yarn and npm for the same project, so you should remove either of package-lock.json and yarn.lock.
In my case it worked as - yarn global add #angular/cli (similarly any dependency)
then added path "C:\Users\USER_NAME\AppData\Local\Yarn\Data\global\node_modules.bin" in "Edit the system environment variables" -> Environment Variables -> Under System Variables select PATH-> click New -> Add the above path then save-> Open new command prompt -> run the dependency command.
yarn install --force
From Yarn's help text on the install command:
--force   install and build packages even if they were built before, overwrite lockfile
I had a situation where nom install would install everything and yarn install wouldn't. So maybe try the other package manager?

Resources