Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
AJ ONeal | a431978582 | |
AJ ONeal | 6c3fa218ba | |
AJ ONeal | 79d4d239ad | |
AJ ONeal | 60f206373c | |
AJ ONeal | 22c741817c | |
AJ ONeal | 1f3a195fe9 | |
AJ ONeal | c3890ca8a9 | |
AJ ONeal | 689fa58531 | |
AJ ONeal | 895dcd31f2 | |
AJ ONeal | b8acbae85f | |
AJ ONeal | 509ee32688 | |
AJ ONeal | 3109f4bb94 | |
AJ ONeal | 05199bcf82 | |
AJ ONeal | 1387929dfc | |
AJ ONeal | c15264b763 | |
AJ ONeal | 8be0a29b7d | |
AJ ONeal | 972d510f59 | |
AJ ONeal | 92ec7ad5b6 | |
AJ ONeal | 95c0caf4be | |
AJ ONeal | ed24276356 | |
AJ ONeal | dddf31db8d | |
AJ ONeal | a1af3328cb | |
AJ ONeal | 515bdce8c2 |
152
README.md
152
README.md
|
@ -1,111 +1,104 @@
|
|||
# STOP
|
||||
|
||||
The install method in this repo still has its place, but this is no longer maintained.
|
||||
|
||||
**Update**: Use [Webi](https://webinstall.dev) instead:
|
||||
|
||||
```sh
|
||||
curl https://webinstall.dev/node | bash
|
||||
```
|
||||
|
||||
# Easy Install node.js
|
||||
|
||||
| Sponsored by [ppl](https://ppl.family) |
|
||||
| A [Root](https://rootprojects.org) Project |
|
||||
|
||||
Automated node.js installers for OS X and Ubuntu
|
||||
Simple node.js installer for macOS and Linux
|
||||
|
||||
**node.js only** (no dev tools)
|
||||
## QuickStart
|
||||
|
||||
```bash
|
||||
# install node.js without development dependencies
|
||||
curl -fsSL https://bit.ly/node-installer | bash -s -- --no-dev-deps
|
||||
|
||||
# using wget instead of curl (Ubuntu)
|
||||
wget -nv https://bit.ly/node-installer -O - | bash -s -- --no-dev-deps
|
||||
curl -fsL bit.ly/node-installer | bash
|
||||
```
|
||||
|
||||
**node.js + dev tools**
|
||||
|
||||
Install node.js and basic development tools - git, node, gcc, pkg-config, etc
|
||||
|
||||
```bash
|
||||
curl -fsSL https://bit.ly/node-installer -o ./node-installer.sh; bash ./node-installer.sh --dev-deps
|
||||
|
||||
# or wget
|
||||
wget -nv https://bit.ly/node-installer -O - ./node-installer.sh; bash ./node-installer.sh --dev-deps
|
||||
```
|
||||
|
||||
*Note*: [bit.ly/node-installer](https://bit.ly/node-installer) simple redirects to <https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master/install.sh>
|
||||
*Note*: [bit.ly/node-installer](https://bit.ly/node-installer) is a redirect to <https://git.coolaj86.com/coolaj86/node-installer.sh/raw/master/install.sh>
|
||||
|
||||
## Screencast
|
||||
|
||||
[How to Setup a VPS for node.js Development](https://www.youtube.com/watch?v=ypjzi1axH2A) - [(3:06 installing node.js](https://www.youtube.com/watch?v=ypjzi1axH2A#t=186))
|
||||
|
||||
## Options
|
||||
## Installer Options
|
||||
|
||||
### Choosing a specific version
|
||||
* [x] version
|
||||
* [x] install location
|
||||
* [x] tools for building native modules
|
||||
|
||||
**Latest**
|
||||
### Choose Version
|
||||
|
||||
The latest version of node is installed by default.
|
||||
|
||||
You can choose a specific version by defining `NODE_VERSION` in the format `vX`, `vX.Y`, or `v.X.Y.Z`:
|
||||
|
||||
```bash
|
||||
export NODEJS_VER=""
|
||||
NODE_VERSION=v10
|
||||
```
|
||||
|
||||
**Exact**
|
||||
Usage:
|
||||
|
||||
```bash
|
||||
export NODEJS_VER="v10.2.1"
|
||||
export NODE_VERSION=v10.10
|
||||
curl -fsSL https://bit.ly/node-installer | bash
|
||||
```
|
||||
|
||||
**Latest of vX.Y.Z**
|
||||
### Location
|
||||
|
||||
By default node will be installed to `/usr/local`, without root if possible.
|
||||
|
||||
You can choose a specific location by setting **both** `NPM_CONFIG_PREFIX` **and** `NODE_PATH`:
|
||||
|
||||
```bash
|
||||
export NODEJS_VER="v8.1"
|
||||
export NPM_CONFIG_PREFIX=$HOME/.local
|
||||
export NODE_PATH=$NPM_CONFIG_PREFIX/lib/node_modules
|
||||
curl -fsSL https://bit.ly/node-installer | bash
|
||||
```
|
||||
|
||||
**Latest of vX.YY.Z**
|
||||
If you want to add the install location to your `PATH`, add `/bin` to the custom location used above and append it like so:
|
||||
|
||||
```bash
|
||||
# latest of v8.11.x
|
||||
export NODEJS_VER="v8.11"
|
||||
PATH=$PATH:$HOME/.local/bin
|
||||
```
|
||||
|
||||
**Latest of vX.Y**
|
||||
### Development Tools
|
||||
|
||||
If you plan on building or creating native node modules, you'll want to install `gcc`, `pgk-config`, and a few other required tools and niceties.
|
||||
|
||||
In fact, it's fairly common for modules to have both native module and pure js dependencies, so you'll probably want (or need) to install these even if you don't plan to use them directly.
|
||||
|
||||
* [x] curl & wget
|
||||
* [x] git
|
||||
* [x] rsync
|
||||
* [x] xcode, brew (on macOS), build-essential (Linux)
|
||||
* [x] gcc, pkg-config
|
||||
* [x] pkg-config
|
||||
* [x] node.js, jshint
|
||||
|
||||
Pass `--dev-deps` to the installer script and it will use either `brew` (on macOS) or `apt` (on Linux) to install the development tools.
|
||||
|
||||
```bash
|
||||
export NODEJS_VER="v10"
|
||||
curl -fsSL https://bit.ly/node-installer | bash -s -- --dev-deps
|
||||
```
|
||||
|
||||
Fun FYI, here's how the latest version is determined:
|
||||
|
||||
Or, if you don't have `curl` installed yet you can use `wget`:
|
||||
```bash
|
||||
NODEJS_VER=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | head -1 )
|
||||
echo "The current node.js version is $NODEJS_VER"
|
||||
wget -nv https://bit.ly/node-installer -O - | bash -s -- --dev-deps
|
||||
```
|
||||
|
||||
```bash
|
||||
BASE_VER="v10\\."
|
||||
NODEJS_VER=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | grep $BASE_VER | head -1 )
|
||||
echo "Latest node.js $BASE_VER is $NODEJS_VER"
|
||||
```
|
||||
### Securing your server
|
||||
|
||||
### Choosing an install location
|
||||
If you're running a node.js server on anything with a public ip address
|
||||
(an "edge" server), I'd highly recommend that you also install `fail2ban` to secure ssh -
|
||||
especially if you haven't switched your server to use key-only authentication (which you should also do).
|
||||
|
||||
Just set BOTH `NODE_PATH` and `NPM_CONFIG_PREFIX`.
|
||||
The install path will be the preceding `lib/node_modules`
|
||||
(which you usually want to be the same as `NPM_CONFIG_PREFIX` anyway).
|
||||
|
||||
```bash
|
||||
export NPM_CONFIG_PREFIX=/tmp/usr/local
|
||||
export NODE_PATH=/tmp/usr/local/lib/node_modules
|
||||
```
|
||||
|
||||
A more realistic example for a self-contained node app:
|
||||
```bash
|
||||
export NPM_CONFIG_PREFIX=/opt/my-app
|
||||
export NODE_PATH=/opt/my-app/lib/node_modules
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
curl -fsSL https://bit.ly/node-installer -o ./node-installer.sh; bash ./node-installer.sh --dev-deps
|
||||
```
|
||||
|
||||
If you want to add the install location to your `PATH`:
|
||||
|
||||
```bash
|
||||
PATH=$PATH:/tmp/user/local/bin
|
||||
```
|
||||
See [The 15-Minute Guide to Secure VPS Access (for the Semi-Paranoid)](https://www.youtube.com/watch?v=YZzhIIJmlE0)
|
||||
|
||||
## Notes
|
||||
|
||||
|
@ -145,18 +138,17 @@ curl -fsSL https://bit.ly/node-installer -o /tmp/node-installer.sh; bash /tmp/no
|
|||
wget -nv https://bit.ly/node-installer -O /tmp/node-installer.sh; bash /tmp/node-installer.sh --dev-deps
|
||||
```
|
||||
|
||||
### Other things you should know
|
||||
### Automatic Version Detection
|
||||
|
||||
This is what gets installed with the dev dependencies:
|
||||
Fun FYI, here's how the latest version is determined:
|
||||
|
||||
* rsync
|
||||
* curl
|
||||
* wget
|
||||
* git
|
||||
* xcode / brew / build-essential / pkg-config / gcc
|
||||
* node (including npm)
|
||||
* jshint
|
||||
```bash
|
||||
NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | head -1 )
|
||||
echo "The current node.js version is $NODE_VERSION"
|
||||
```
|
||||
|
||||
**NOTE**: If you're running a node.js server on an edge server,
|
||||
I'd highly recommend that you also install `fail2ban` to secure ssh -
|
||||
especially if you haven't switched your server to use key-only authentication.
|
||||
```bash
|
||||
BASE_VER="v10\\."
|
||||
NODE_VERSION=$(curl -fsSL https://nodejs.org/dist/index.tab | tail -n +2 | cut -f 1 | grep $BASE_VER | head -1 )
|
||||
echo "Latest node.js $BASE_VER is $NODE_VERSION"
|
||||
```
|
71
install.sh
71
install.sh
|
@ -33,7 +33,7 @@ NO_FAIL2BAN="nope"
|
|||
OS="unsupported"
|
||||
ARCH=""
|
||||
SETUP_FILE=""
|
||||
my_tmp=$(mktemp -d)
|
||||
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||
export my_tmp
|
||||
|
||||
clear
|
||||
|
@ -56,37 +56,38 @@ if [ "$(uname | grep -i 'Darwin')" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OSX_MAJOR" -gt 10 ]; then
|
||||
echo "unsupported OS X version (os 11+)"
|
||||
exit 1
|
||||
# Mavericks+ works for all current macOS versions
|
||||
OS='mavericks'
|
||||
|
||||
if [[ "$OSX_MAJOR" -eq 10 ]]; then
|
||||
#
|
||||
# Minor
|
||||
#
|
||||
if [ "$OSX_MINOR" -le 5 ]; then
|
||||
echo "unsupported OS X version (os 10.5-)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Snow
|
||||
if [ "$OSX_MINOR" -eq 6 ]; then
|
||||
OS='snow'
|
||||
fi
|
||||
|
||||
# Lion
|
||||
if [ $OSX_MINOR -eq 7 ]; then
|
||||
OS='lion'
|
||||
fi
|
||||
|
||||
# Mountain Lion
|
||||
if [ "$OSX_MINOR" -eq 8 ]; then
|
||||
OS='mountain'
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Minor
|
||||
#
|
||||
if [ "$OSX_MINOR" -le 5 ]; then
|
||||
echo "unsupported OS X version (os 10.5-)"
|
||||
exit 1
|
||||
fi
|
||||
# OS X (10) and macOS (11) should be supported
|
||||
|
||||
# Snow
|
||||
if [ "$OSX_MINOR" -eq 6 ]; then
|
||||
OS='snow'
|
||||
fi
|
||||
|
||||
# Lion
|
||||
if [ $OSX_MINOR -eq 7 ]; then
|
||||
OS='lion'
|
||||
fi
|
||||
|
||||
# Mountain Lion
|
||||
if [ "$OSX_MINOR" -eq 8 ]; then
|
||||
OS='mountain'
|
||||
fi
|
||||
|
||||
# Mavericks, Yosemite
|
||||
if [ "$OSX_MINOR" -ge 9 ]; then
|
||||
OS='mavericks'
|
||||
if [ "$OSX_MAJOR" -gt 11 ]; then
|
||||
echo "WARNING: macOS 12+ may or may not be supported"
|
||||
fi
|
||||
|
||||
if [ -n "$(sysctl hw | grep 64bit | grep ': 1')" ]; then
|
||||
|
@ -231,6 +232,12 @@ fi
|
|||
# Which node.js VERSION ? #
|
||||
#########################
|
||||
|
||||
NODE_VERSION=${NODE_VERSION:-}
|
||||
NODEJS_VER=${NODEJS_VER:-}
|
||||
if [ -n "$NODE_VERSION" ]; then
|
||||
NODEJS_VER=$NODE_VERSION
|
||||
fi
|
||||
|
||||
if [ -z "${NODEJS_VER:-}" ]; then
|
||||
# For backwards compat
|
||||
if [ -f "$my_tmp/NODEJS_VER" ]; then
|
||||
|
@ -314,8 +321,8 @@ if [ -n "${NODEJS_VER}" ]; then
|
|||
bash "$my_tmp/${INSTALL_FILE}" "${NODEJS_VER}"
|
||||
fi
|
||||
|
||||
mkdir -p $node_install_path/lib/node_modules || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
|
||||
chown -R $(whoami) $node_install_path/lib/node_modules || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
|
||||
mkdir -p $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd mkdir -p $node_install_path/lib/node_modules
|
||||
chown -R $(whoami) $node_install_path/lib/node_modules 2> /dev/null || $sudo_cmd chown -R $(whoami) $node_install_path/lib/node_modules
|
||||
|
||||
echo ""
|
||||
|
||||
|
@ -376,3 +383,5 @@ if [ "--dev-deps" == "$deps_flag" ]; then
|
|||
|
||||
echo ""
|
||||
fi
|
||||
|
||||
rm -rf "$my_tmp"
|
|
@ -9,7 +9,7 @@ set -u
|
|||
set -o pipefail
|
||||
|
||||
if [ -z "${my_tmp-}" ]; then
|
||||
my_tmp=$(mkdir -p)
|
||||
my_tmp="$(mktemp -d -t node-installer.XXXXXXXX)"
|
||||
fi
|
||||
if [ -z "${PREFIX-}" ]; then
|
||||
PREFIX=""
|
||||
|
@ -72,14 +72,16 @@ if [ -n "${NODEJS_VER}" ]; then
|
|||
rm -rf ${NODEJS_UNTAR}/${NODEJS_NAME}-${NODEJS_VER}-linux-${ARCH} # clean up the temporary unzip folder
|
||||
rm ${NODEJS_UNTAR}/{LICENSE,CHANGELOG.md,README.md}
|
||||
if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
|
||||
echo $sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||
rsync -a "${NODEJS_UNTAR}/" "$node_install_path/" || $sudo_cmd rsync -a "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||
echo $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||
rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/" 2>/dev/null || $sudo_cmd rsync -Krl "${NODEJS_UNTAR}/" "$node_install_path/"
|
||||
else
|
||||
echo $sudo_cmd cp -a "${NODEJS_UNTAR}/*" "$node_install_path/"
|
||||
cp -a "${NODEJS_UNTAR}"/* "$node_install_path/" || $sudo_cmd cp -a "${NODEJS_UNTAR}"/* "$node_install_path/"
|
||||
# due to symlink issues on Arch Linux, don't copy the share directory
|
||||
rm -rf ${NODEJS_UNTAR}/share
|
||||
echo $sudo_cmd cp -Hr "${NODEJS_UNTAR}/*" "$node_install_path/"
|
||||
cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/" 2>/dev/null || $sudo_cmd cp -Hr "${NODEJS_UNTAR}"/* "$node_install_path/"
|
||||
fi
|
||||
rm -rf "${NODEJS_UNTAR}"
|
||||
|
||||
chown -R $(whoami) "$node_install_path/lib/node_modules/" || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
||||
chown $(whoami) ""$node_install_path"/bin/" || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
|
||||
chown -R $(whoami) "$node_install_path/lib/node_modules/" 2>/dev/null || $sudo_cmd chown -R $(whoami) "$node_install_path/lib/node_modules/"
|
||||
chown $(whoami) ""$node_install_path"/bin/" 2>/dev/null || $sudo_cmd chown $(whoami) ""$node_install_path"/bin/"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue