I am trying to add vtex using yarn but getting below error,
Usage Error: The 'yarn global' commands have been removed in 2.x - consider using 'yarn dlx' or a third-party plugin instead
yarn version: 3.2.0
Node: 16.14.0
NPM: 8.5.2
OS Details: MacOS Monterey, chip: apple m1 pro
Thanks in advance.
quick answer
Did you try to use yarn dlx instead of yarn global (removing the word add)? The resulting command:
yarn dlx vtex
explanation & official doc reference
The above command is what the instruction in the error message means to recommend. Granted, "consider using 'yarn dlx' or a third-party plugin instead", could be clearer. Nonetheless it has some useful info.
The yarn dlx documentation is probably more to the point. Their example:
yarn dlx create-react-app ./my-app
The documentation explains that the dlx command uses a temporary environment in place of using global packages.
Most package manager maintainers have come to the conclusion that global package versions are problematic. You can find various discussions of why package manager maintainers are giving (and encouraging) alternatives, usually citing the issues developers encounter with different projects requiring different versions.
In any case, it's hard to argue that the best option is downgrading. Likely you'll not regret trying the up-to-date approach.
On mac OS check yarn version by running command in terminal,
yarn --version
If it is greater than or equal to 2. Please downgrade yarn version to 1.xx.x using,
yarn set version 1.22.1
Related
I read that on OS X you can install Yarn either by
curl -o- -L https://yarnpkg.com/install.sh | bash
brew install yarn
npm i -g yarn
What functional difference is there between these three methods? Why would someone choose one over the others?
when using brew to install packages, you install them system wide. that is, you cannot have more than one version for the same package, which is usually problematic. for this reason, many other technologies have spawn, such as docker, snap.
moreover, each package manager has its own lifecycle and packs original package in a different manner for ease of use, distribution and maintenance. for instance, npm container is based on the release of npm package itself.
usually, you should stick to the package manager of the same ecosystem that you are using. specifically to your case, it will be recommended to use npm to install and update your package (using package.json). which will give each of your project to pin and lock the desired yarn version that you like, without any affecting your system wide.
speaking of npm, you might wish to look at this answer
curl downloads the installation script from yarnpkg.com, and installs yarn using that script
brew is a package manager for MacOS. It's meant to make things easier for people when installing commands for the terminal. When you install with brew, the package get's put into /usr/local/bin instead of /usr/bin so I believe that this is kind of like a virtual environment, and yarn wouldn't be installed into the core of your machine. You'll have to install homebrew before you can use it, and you install it using curl. I believe that there is less risk when using homebrew because of the reasons that it is kind of like a virtual environment
npm is a package manager for javascript, it's the same as yarn. It's meant for easy installation of javascript packages.
I use brew for all installs to the terminal, and npm for all installs of javascript packages.
I'm using macOS and after installing Yarn2 several important tools no longer function. I've logged issues with them but in the meantime I need to get back to Yarn Classic. brew uninstall yarn and then tried brew install yarn#1.22.5 but this failed with an unknown version error message.
Trick is to check for a ~/.yarnrc.yml file and if present remove any line for the yarnPath variable.
I know there are two yarns:
Yarn, the node.js package manager
Apache Hadoop's Yarn
I noticed that both commands work fine:
yarn --version
yarnpkg --version
Is yarnpkg a CLI alias that yarn, the node.js package manager, implemented to avoid conflicts?
You can check if they point to the same binary by typing which yarn and which yarnpkg.
If they point to the same binary file then it's just an alias or a symlink, but if not, then they are not the same, although it is most likely that they both do the same job, and it is just that apache named it differently.
(Debian's yarn also uses yarnpkg)
There is a nasty bug in Docker 1.9.x that is causing java
processes to hang and frankly hang up the entire container
instance, spinning 100% CPU.
I currently have docker 1.9.1 installed because that is all that
the docker install tool will install. There is no opportunity during
the install process to select any other version.
This is completely preventing me from building a cordova
build container. In my internet research I have found many
others who are encountering the same problem.
I've done some research and seen that others are reporting this
problem does not occur with Docker 1.8.3.
I've searched in vain for some hints on how to install older versions
of docker on OS-X. I tried replacing the boot2docker.iso in ~/.docker/machine/machines/default with the 1.8.3 version downloaded
from here: https://github.com/boot2docker/boot2docker/releases/tag/v1.8.3 but that fails miserably. I am guessing that there are other things about my default machine (which had been created with 1.9.1) that are incompatible with it.
If anybody has hints as to how I could create a new machine or modify
the existing machine to work with 1.8.3 I would very much appreciate
it.
Alternatively, let me know if there is some other installation method that would allow me to specify which version of docker to install.
I figured out that what I needed to do is to find an older version of DockerToolbox and that would install the version of docker that I wanted.
I went to the github repository for DockerToolbox:
https://github.com/docker/toolbox/releases?after=v1.9.
and there I found a link to the 1.8.3 binary:
https://github.com/docker/toolbox/releases/download/v1.8.3/DockerToolbox-1.8.3.pkg
I still had to uninstall my previous installation of docker so I followed the uninstall instructions on this page:
https://medium.com/#itseranga/install-old-version-of-docker-osx-c92ebd5f15f7#.5qh1z0ino
Once I had uninstalled and reinstalled via the legacy DockerToolbox, I managed to build the cordova container:
https://github.com/oren/docker-cordova
without incident.
I've been using the following:
https://get.docker.com/builds/$(uname -s)/$(uname -m)/docker-.tgz
See https://github.com/docker/for-mac/issues/1120.
If you happen to know the build number (e.g. 14937) -- not the git commit you see when running docker --version or docker version -- you can form the URL:
https://download.docker.com/mac/{{ beta | stable}}/{{ version }}.{{ build number }}/Docker.dmg
# example:
https://download.docker.com/mac/stable/1.12.6.14937/Docker.dmg
I've been trying to get past step one of installing grails, which is bad i know. But the issue im having is getting grails to work via the OSX terminal. similar to node using brew I type the command
brew install grails
this retrieves grails and installs it, simple. to see if its installed correctly you type grails -version
However when i do that it's as though my terminal restarts. Its a hard thing to describe so here is a link to a youtube video that shows you what happens. I have JAVA installed and working. Anyone have an idea?
https://www.youtube.com/watch?v=ButLwGfBTZo
As this is the first excursion I have had into any Java related development. I made a rookie mistake and was unaware of vital piece of information. You do not need Java to run Grails you need the Java Development Kit (JDK). Which is a different thing completely apparently.
Available here
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Once installed run this command in the terminal /usr/libexec/java_home -V This will show you all of the current Java Virtual Machines installed. In my case
Matching Java Virtual Machines (1):
1.8.0_11, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
You then need to set your JAVA_HOME Environment variable to point to your JVM. Like so export JAVA_HOME=$(/usr/libexec/java_home) use /usr/libexec/java_home rather than the true location as this will specifi the version set in Java Preferences for the current user. The source for that nice little trick is here http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/
Once you've done that you can type the command brew install grails or gvm install grails which is what i should probably use rather than brew as "SurrealAnalysis" rightly pointed out in one of the answers.
moment of truth grails -version and i got a response Grails version: 2.4.3... sweet.
Thank you all for the replies and help.
Following previous post, GVM it is not available in Homebrew, because of this.
GDK is also now officially SDKMAN!.
So, the steps would be:
curl -s "https://get.sdkman.io" | bash
source "/Users/{YOUR_USER_NAME}/.sdkman/bin/sdkman-init.sh"
sdk install groovy
Hope it helps! :)