From 4ef5a64bd9eb6653ac6e41569a0478b8df6157d0 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 19 Apr 2018 19:37:06 +0200 Subject: [PATCH] Created Install package manager (markdown) --- Install-package-manager.md | 117 +++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 Install-package-manager.md diff --git a/Install-package-manager.md b/Install-package-manager.md new file mode 100644 index 0000000..0c6d7de --- /dev/null +++ b/Install-package-manager.md @@ -0,0 +1,117 @@ +Before you can install the required packages we need a node package manager. The two most popular are [npm](https://npmjs.com) and [yarn](https://yarnpkg.com/en/) so I will cover how to install them below. + +# Table of contents +- [Yarn](#yarn) + * [macOS](#yarn_macos) + * [Debian / Ubuntu](#yarn_debian-ubuntu) + * [CentOS / Fedora / RHEL](#yarn_centos-fedora-rhel) +- [NPM](#npm) + * [macOS](#npm_macos) + * [unix](#npm_unix) + +# Yarn +## macOS +### Homebrew +You can install Yarn through the [homebrew package manager](https://brew.sh/). This will also install Node.js if it not already installed. + +``` +brew install yarn +``` +If you use [nvm](https://github.com/creationix/nvm) or similar, you should exclude installing Node.js so that nvm's version of Node.js is used. + +``` +brew install yarn --without-node +``` + +### MacPorts +You can install Yarn through [MacPorts](https://www.macports.org/). This will also install Node.js if it not already installed. + +``` +sudo port install yarn +``` + +### Path Setup + +If you chose manual installation, the following steps will add Yarn to path variable and run it from anywhere. + +Note: your profile may be in your `.profile`, `.bash_profile`, `.bashrc`, `.zshrc`, etc. + +Add this to your profile: `export PATH="$PATH:/opt/yarn-[version]/bin"` (the path may vary depending on where you extracted Yarn to) +In the terminal, log in and log out for the changes to take effect +To have access to Yarn’s executables globally, you will need to set up the `PATH` environment variable in your terminal. To do this, add `export PATH="$PATH:`yarn global bin`"` to your profile. + +### Upgrade Yarn +Yarn will warn you if a new version is available. To upgrade Yarn, you can do so with homebrew. + +``` +brew upgrade yarn +``` + +Test that Yarn is installed by running: + +``` +yarn --version +``` + +## Debian / Ubuntu +On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the repository: + +``` +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +``` + +On Ubuntu 16.04 or below and Debian Stable, you will also need to configure [the NodeSource repository](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions) to get a new enough version of Node.js. + +Then you can simply: +``` +sudo apt-get update && sudo apt-get install yarn +``` +**Note**: Ubuntu 17.04 comes with `cmdtest` installed as default. If you're getting errors from installing `yarn`, you may want to run `sudo apt remove cmdtest` first. Refer to [this](https://github.com/yarnpkg/yarn/issues/2821) for more information. + +If you use `nvm` you can avoid the `node` installation by doing: +``` +sudo apt-get install --no-install-recommends yarn +``` +**Note**: Due to the use of `nodejs` instead of `node` name in some distros, `yarn`might complain `node` not being installed, a workaround for this is to add an alias in your `.bashrc` (or similar), like som: `alias nodejs=node`. This will point `yarn` to whatever version of `node` you decide to use. + +Test that Yarn is installed by running: +``` +yarn --version +``` + +## CentOS / Fedora / RHEL +On CentOs, Fedora and RHEL, you can install Yarn via the RPM package repository for Yarn. (Please see [yarns own pages](https://yarnpkg.com/en/docs/install#centos-stable) if you get any errors when adding the repository.) +``` +curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo +``` + +If you do not already have Node.js installed, you should also configure [the NodeSource repository](https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora): +``` +curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - +``` + +Then you can simply: +``` +sudo yum install yarn +## OR ## +sudo dnf install yarn +``` + +Test that Yarn is installed by running: +``` +yarn --version +``` + +# NPM +npm is bundled with node. To check if you have npm already installed run: `npm --version` + +## macOS +Download and run the npm program [pkg from nodejs.org](https://nodejs.org/en/download/) + +## Manual install on unix systems +There's a pretty robust install script at [https://www.npmjs.com/install.sh](https://www.npmjs.com/install.sh). You can download that and run it. +Here's how to download and run it with curl: +``` +curl -L https://www.npmjs.com/install.sh | sh +``` \ No newline at end of file