I used Homebrew to install yarn. Running yarn -v shows that I currently use 0.23.2. I ran brew upgrade yarn to get the latest version, which is 0.24.6.
After Homebrew successfully upgrades yarn, I run yarn -v again, but the version is still 0.23.2. How can I change the version of yarn that I am running?
yarn policies set-version <version number>
Per https://github.com/yarnpkg/yarn/issues/7146#issuecomment-477809216
You can use homebrew and yarn formula URLs to install older versions of yarn, then brew switch between yarn versions as needed. Works perfectly! Credit to github user robertmorgan.
First off, if you already have a version installed, unlink it from brew running the brew unlink yarn command in your terminal.
Next, in a web browser, find the Pull Request that has been merged which contained the formula (version) of
Yarn
that you want to install.
View the files changed in that Pull Request - there should be one for Formula/yarn.rb.
Click the "View" button for the Formula/yarn.rb file to see the whole contents of the file for that commit.
Click the button to view the "Raw" version of that file. This will open a url which should start with
https://raw.githubusercontent.com/....
This is the URL that you will need for the next step - so copy the complete URL to your clipboard.
Back in your terminal window, use the command brew install followed by the URL that you've copied.
e.g. to install v1.6.0 of yarn it would be:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/fba7635ab69384ac980c635483a7af825bc06088/Formula/yarn.rb
You can then verify the versions available to Homebrew by running:
brew list --versions yarn, and switch between versions using brew switch yarn VERSION_NUMBER
Source: https://github.com/yarnpkg/yarn/issues/1882#issuecomment-421372892
I found an answer. It's not the prettiest, but since yarn always tell me what the most update-to-date version is, I can use npm to just install the latest version.
If the latest is 0.24.6
npm install --global yarn#.24.6
EDIT:
According to yarn's official documentation, the way to install/upgrade is:
brew install yarn
brew upgrade yarn
https://yarnpkg.com/en/docs/install#mac-stable
Your best bet would be to use a yarn version manager.
Install:
curl -fsSL https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.sh | bash
Single usage:
yvm exec <version> <command>
Or to switch your currently running yarn version
yvm use <version>
yarn --version
UPDATE Dec 2021:
Sadly brew switch is deprecated in Homebrew 2.6.0 (December 2020)
$ brew switch
Error: Unknown command: switch
TLDR, to switch version:
brew unlink yarn
brew link yarn#<new_version>
Old solution:
Assuming that you have the other version installed, you can run
brew switch yarn <old_version>
To list the versions you have installed:
brew list --versions yarn
You can use
yarn set version <version>
For example, if you want the latest version, you can run
yarn set version latest
You can also set it to a specific number, for example,
yarn set version 1.22.1
You can view the full documentation at the official website.
Note 1: A bug stops you from switching from yarn 2 to yarn 1. There are solutions to this in this GitHub issue.
Note 2: I don't use brew, but this solution should still work.
Easily install and switch between any number of yarn versions.
https://github.com/tophat/yvm
Here's a way to do it with only curl and bash:
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.24.6 # or another version
This works whether you have yarn installed or not.
For updating version on macOS use below command:
$ brew upgrade yarn
Some of the above answers don't seem to work anymore. Here is how I was able to install a different version in April 2021:
brew unlink yarn#1.6.0 (If you already have a version installed)
brew extract --version 1.22.4 yarn homebrew/cask
brew install yarn#1.22.4
yarn -v
Related
I am trying to run my React project by npm start but get following error.
nodenv: version `8.9.1' is not installed
(set by /Users/xyz/github-repos/react/.node-version)
A oneliner solution might be:
nodenv install $(cat .node-version)
print the version specified in .node-version
use that as input for the nodenv install command
If your environment is setup correctly, there is no need to redefine the local version with nodenv local. The version is already saved in the aforementioned .node-version file.
You would run nodenv local <version> on the first system where you define the project's nodejs version to write the preferred nodejs version to .node-version.
Running yarn or yarn install is not part of the requirements to run the correct nodejs version in the project's directory. Running yarn will install the dependencies specified in package.json.
on mac I had to first do
brew upgrade nodenv node-build
then I could do
nodenv install 8.9.1
nodenv local 8.9.1
Following commands fixed my problem
nodenv install 8.9.1
nodenv local 8.9.1
yarn install
I tried to use pip install, but it tells cannot find such package.
I also see someone say we can use brew and nodejs to install. This is what I tried to install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It returns that ruby doesn't found.
I have no idea about nodejs.
Anyone knows how can I install PhantomJS in the server?
Meet npm!
Npm stands for Node Package Manager.
You can install packages for using them from the CLI or from your nodejs app.
You can install NPM from here.
If node isn't installed yet, you can use NVM, which makes it really easy -
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
For your question,
See this specific package.
You can install it via:
$ npm install phantomjs-prebuilt
And then you should be able to: $ bin/phantomjs [phantom arguments] to run phantomJS from the terminal.
PhantomJS is a standalone application with its own website which has binaries for all major platforms and documentation. You don't really need pip or npm or bundler to install it, just do it manually.
Go to http://phantomjs.org/download.html
Choose the appropriate binary (Linux x32 x64 / OSX / Windows), download archive, extract it and run the binary.
For example you have a x64 Linux distribution.
Log in to your server via ssh.
Go to your home directory:
cd ~
Download PhantomJS binary:
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Extract archive:
tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
A new directory is created: phantomjs-2.1.1-linux-x86_64. The PhantomJS binary is phantomjs-2.1.1-linux-x86_64/bin/phantomjs. You can run it right now:
~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs --version
2.1.1
(If it says "not found " instead that means you chose the wrong distribution, e.g. x64 instead of x32).
But this way of running it is inconvenient. It would be way better to be able to just type phantomjs script.js in any directory. To make it so add a link to a directory where binaries are kept by default:
sudo ln -s ~/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
Then you can call PhantomJS from anywhere:
cd /var/www/
phantomjs --version
2.1.1
I want to install the latest minor/patch version of NodeJS 4 using nvm. I don't just want "latest", because that would be NodeJS 8 or whatever later, potentially breaking-change version is out now.
If it were an npm dependency, I would be able to say nvm install "^4", but that doesn't work. Is there a simple command to do this? If there isn't, is there something I can do on the command line to find the latest version and install it in a one-liner that works on both Windows and Unix-based consoles?
(nvm maintainer here)
If you run nvm --help (make sure you're using the latest version of nvm), you'll see a description of all the things nvm supports. Specifically, nvm does not support semver ranges, however, nvm install 4 or nvm install 4.x will install the latest available version of node 4.
Separately, you can use nvm install --lts=argon (and nvm alias default lts/argon if you want to peg to the LTS line specifically instead of just v4.
Hello Since the big rename of k to dnx I have no idea how to install the tools on my mac?
the documentation on the dev branch has not been updated to reflect the big rename
https://github.com/aspnet/Home/tree/dev
The homebrew-k was updated recently to support dnvm. Here the instructions:
Install Homebrew if it is not already installed.
Run command brew tap aspnet/k to tap the ASP.NET 5 related git repositories. If you had already tapped the repo for previous releases, run brew untap aspnet/k to delete the old commands and tap again to get the updated brew scripts
Run command brew install dnvm to install dnvm. This will automatically install the latest DNX package from https://www.nuget.org/api/v2 feed
Run command source dnvm.sh on your terminal if your terminal cannot understand dnvm
EDIT
Homebrew-K was renamed to Homebrew-dnx so now you should use
brew tap aspnet/dnx
If you tapped aspnet/k it is probably not a bad idea to untap it (brew untap aspnet/k) and update brew (brew update)
Just installed phantomjs, mac os x yosemite. Whenever I run /bin/phantomjs, with any parameter, I get Killed: 9. Any idea?
Install UPX. UPX is an executable packer and unpacker
$ brew install upx
Unpack the phantomjs executable
$ upx -d phantomjs-2.0.0-macosx/bin/phantomjs
Run the phantomjs executable
$ ./phantomjs-2.0.0-macosx/bin/phantomjs
re: running phantomjs on osx yosemite, download the build/fix found at:
https://github.com/eugene1g/phantomjs/releases
original issue:
https://github.com/ariya/phantomjs/issues/12928
The eugene1g release and UPX install didn't work for me on El Capitan. What did work for me was installing PhantomJS using the phantomjs2 NPM package:
npm install phantomjs2
# Optional: symlink in a dir that's on my PATH:
ln -s /usr/local/lib/node_modules/phantomjs2/lib/phantom/bin/phantomjs /usr/local/bin/phantomjs
$ npm install -g phantomjs worked for me on El Capitan.
The npm package isn't "official", it's maintained by a contributor, but it works. https://github.com/eugene1g/phantomjs
Blunt re-install using brew
Whatever is in /usr/local/bin/phantomjs has stopped working for you.
If you've got ~30mins to spare you can reinstall and relink using brew:
# unlink old version
brew unlink phantomjs
# reinstall phantomjs
brew update && brew install phantomjs
# (You may wish to make a refreshing herbal tea or similar beverage here...)
# Update link to usr/local/bin
brew link --overwrite phantomjs
If you want to test what brew will do with overwrite you can run
brew link --overwrite --dry-run phantomjs
Sometimes this happens when your current shell process is killed.
I was in tmux using brew update, and brew updated tmux and bash, then bang! Everything in tmux just returns Killed: 9.