Skip to content

Instantly share code, notes, and snippets.

@justinhartman
Last active August 17, 2022 13:20
Show Gist options
  • Save justinhartman/101c5b610f02e4f176efdebdd0ad9c8b to your computer and use it in GitHub Desktop.
Save justinhartman/101c5b610f02e4f176efdebdd0ad9c8b to your computer and use it in GitHub Desktop.
Replace NPM with Yarn as global package manager

List installed NPM global packages

$ npm list -g --depth 0
~/.nvm/versions/node/v16.13.2/lib
├── corepack@0.10.0
├── eas-cli@0.52.0
├── expo-cli@5.4.7
├── npm@8.1.2
└── yarn@1.22.18

NB: You need to keep corepack, yarn and npm for yarn global to work.

Uninstall packages to migrate

$ npm uninstall -g eas-cli expo-cli
$ npm list -g --depth 0
~/.nvm/versions/node/v16.13.2/lib
├── corepack@0.11.2
├── npm@8.1.2
└── yarn@1.22.18

Re-install packages with yarn global

$ yarn global add eas-cli expo-cli
yarn global v1.22.19
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "eas-cli@0.54.1" with binaries:
      - eas
success Installed "expo-cli@5.4.11" with binaries:
      - expo
      - expo-cli
✨  Done in 17.05s

List Yarn global packages installed

$ yarn global list
yarn global v1.22.19
info "eas-cli@0.54.1" has binaries:
   - eas
info "expo-cli@5.4.11" has binaries:
   - expo
   - expo-cli
✨  Done in 4.69s.

Using NVM to install new Node versions

Get list of installed versions

$ nvm ls
       v12.22.6
       v14.17.6
->     v16.13.2
default -> stable (-> v16.13.2)
node -> stable (-> v16.13.2) (default)
stable -> 16.13 (-> v16.13.2) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.19.3 (-> N/A)
lts/gallium -> v16.15.1 (-> N/A)

Install new Node version

Make sure to use these flags to ensure yarn is installed with new NVM versions:

$ nvm install lts/gallium --reinstall-packages-from=stable --latest-npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment