# nodeenv



https://github.com/ekalinin/nodeenv



### Installation locale:

On peut installer dans un environnement virtuel Python (virtualenv ou venv).

```bash
~/Documents/nodeenv master* ⇡
❯ python3 -m venv homebridge

~/Documents/nodeenv master* ⇡
❯ source homebridge/bin/activate

~/Documents/nodeenv master* ⇡
homebridge ❯ pip3 install -U pip setuptools

~/Documents/nodeenv master* ⇡ 7s
homebridge ❯ pip3 install nodeenv

~/Documents/nodeenv master* ⇡
❯ cd homebridge/bin
total 48
-rw-r--r-- 1 bruno staff 8471 Nov  8 20:52 Activate.ps1
-rw-r--r-- 1 bruno staff 2233 Nov  8 20:52 activate
-rw-r--r-- 1 bruno staff 1285 Nov  8 20:52 activate.csh
-rw-r--r-- 1 bruno staff 2437 Nov  8 20:52 activate.fish
-rwxr-xr-x 1 bruno staff  270 Nov  8 20:53 easy_install
-rwxr-xr-x 1 bruno staff  270 Nov  8 20:53 easy_install-3.8
-rwxr-xr-x 1 bruno staff  243 Nov  8 20:54 nodeenv
-rwxr-xr-x 1 bruno staff  261 Nov  8 20:53 pip
-rwxr-xr-x 1 bruno staff  261 Nov  8 20:53 pip3
-rwxr-xr-x 1 bruno staff  261 Nov  8 20:53 pip3.8
lrwxr-xr-x 1 bruno staff    7 Nov  8 20:52 python -> python3
lrwxr-xr-x 1 bruno staff   58 Nov  8 20:52 python3 -> /Applications/Xcode.app/Contents/Developer/usr/bin/python3
```
Pour connaître les versions de node disponibles:

```bash
~/Documents/nodeenv/homebridge master* ⇡ 9s
❯ nodeenv --list
0.1.14	0.1.15	0.1.16	0.1.17	0.1.18	0.1.19	0.1.20	0.1.21
...
14.11.0	14.12.0	14.13.0	14.13.1	14.14.0	14.15.0	15.0.0	15.0.1
15.1.0
```

On installe node:

```bash
~/Documents/nodeenv master* ⇡
homebridge ❯ nodeenv -p --node=14.15.0 env
 * Install prebuilt node (14.15.0) ..... done.

~/Documents/nodeenv master* ⇡
homebridge ❯ node -v
v14.15.0

~/Documents/nodeenv/homebridge/bin master* ⇡ 11s
❯ l
total 72364
-rw-r--r-- 1 bruno staff     8471 Nov  8 20:52 Activate.ps1
-rw-r--r-- 1 bruno staff     6115 Nov  8 21:03 activate
-rw-r--r-- 1 bruno staff     1285 Nov  8 20:52 activate.csh
-rw-r--r-- 1 bruno staff     6627 Nov  8 21:03 activate.fish
-rwxr-xr-x 1 bruno staff      270 Nov  8 20:53 easy_install
-rwxr-xr-x 1 bruno staff      270 Nov  8 20:53 easy_install-3.8
-rwxr-xr-x 1 bruno staff 74032864 Oct 27 12:44 node
-rwxr-xr-x 1 bruno staff      243 Nov  8 20:54 nodeenv
lrwxr-xr-x 1 bruno staff        4 Nov  8 21:03 nodejs -> node
lrwxr-xr-x 1 bruno staff       38 Nov  8 21:03 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxr-xr-x 1 bruno staff       38 Nov  8 21:03 npx -> ../lib/node_modules/npm/bin/npx-cli.js
-rwxr-xr-x 1 bruno staff      261 Nov  8 20:53 pip
-rwxr-xr-x 1 bruno staff      261 Nov  8 20:53 pip3
-rwxr-xr-x 1 bruno staff      261 Nov  8 20:53 pip3.8
-rw-r--r-- 1 bruno staff       65 Nov  8 21:03 predeactivate
lrwxr-xr-x 1 bruno staff        7 Nov  8 20:52 python -> python3
lrwxr-xr-x 1 bruno staff       58 Nov  8 20:52 python3 -> /Applications/Xcode.app/Contents/Developer/usr/bin/python3
-rwxr-xr-x 1 bruno staff      299 Nov  8 21:03 shim
```

On installe l'application:

```bash
~/Documents/nodeenv master* ⇡
homebridge ❯ npm install -g --unsafe-perm homebridge

~/Documents/nodeenv/env/bin master* ⇡
homebridge ❯ npm install -g --unsafe-perm homebridge-config-ui-x

~/Documents/nodeenv/env/bin master* ⇡
homebridge ❯ npm install -g --unsafe-perm homebridge-samsung-tizen

~/Documents/nodeenv/env/bin master* ⇡
homebridge ❯ npm install -g --unsafe-perm homebridge-sonos

~/Documents/nodeenv/env/bin master* ⇡
homebridge ❯ l
total 72312
-rwxr-xr-x 1 bruno staff     3653 Nov  9 07:52 activate
-rwxr-xr-x 1 bruno staff     3970 Nov  9 07:52 activate.fish
lrwxr-xr-x 1 bruno staff       65 Nov  9 08:07 hb-service -> ../lib/node_modules/homebridge-config-ui-x/dist/bin/hb-service.js
lrwxr-xr-x 1 bruno staff       45 Nov  9 08:05 homebridge -> ../lib/node_modules/homebridge/bin/homebridge
lrwxr-xr-x 1 bruno staff       65 Nov  9 08:07 homebridge-config-ui-x -> ../lib/node_modules/homebridge-config-ui-x/dist/bin/standalone.js
-rwxr-xr-x 1 bruno staff 74032864 Oct 27 12:44 node
lrwxr-xr-x 1 bruno staff        4 Nov  9 07:52 nodejs -> node
lrwxr-xr-x 1 bruno staff       38 Nov  9 07:52 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxr-xr-x 1 bruno staff       38 Nov  9 07:52 npx -> ../lib/node_modules/npm/bin/npx-cli.js
-rwxr-xr-x 1 bruno staff      240 Nov  9 07:52 shim
```



### Installation globale:

```bash
$ pip3 install nodeenv
```

Création d'un environnement:
```bash
# Par défaut, nodeenv installe la dernière version de node:

~/Documents/nodeenv master* ⇡
❯ nodeenv homebridge
 * Install prebuilt node (15.1.0) ..... done.
```

```bash
~/Documents/nodeenv master* ⇡
❯ cd homebridge
drwxr-xr-x 9 bruno staff 288 Nov  8 16:03 bin
drwxr-xr-x 3 bruno staff  96 Nov  4 20:39 include
drwxr-xr-x 4 bruno staff 128 Nov  4 20:39 lib
drwxr-xr-x 5 bruno staff 160 Nov  4 20:39 share
drwxr-xr-x 3 bruno staff  96 Nov  8 16:03 src

~/Documents/nodeenv/homebridge master* ⇡
❯ cd bin
total 75420
-rwxr-xr-x 1 bruno staff     3674 Nov  8 16:03 activate
-rwxr-xr-x 1 bruno staff     3977 Nov  8 16:03 activate.fish
-rwxr-xr-x 1 bruno staff 77214592 Nov  4 20:39 node
lrwxr-xr-x 1 bruno staff        4 Nov  8 16:03 nodejs -> node
lrwxr-xr-x 1 bruno staff       38 Nov  8 16:03 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxr-xr-x 1 bruno staff       38 Nov  8 16:03 npx -> ../lib/node_modules/npm/bin/npx-cli.js
-rwxr-xr-x 1 bruno staff      268 Nov  8 16:03 shim
```

Activer l'environnement fonctionne uniquement sous bash, ni zsh, ni fish.

```bash
~/Documents/nodeenv master* ⇡ 7s
❯ homebridge/bin/node -v
v15.1.0
```

Pour installer une version précise de node:

```bash
~/Documents/nodeenv master* ⇡
❯ nodeenv --node=14.15.0 homebridge
 * Install prebuilt node (14.15.0) ..... done.
```

```bash
~/Documents/nodeenv master* ⇡ 7s
❯ homebridge/bin/node -v
v14.15.0
```

Pour connaître les versions disponibles:

```bash
~/Documents/nodeenv/homebridge master* ⇡ 9s
❯ nodeenv --list
0.1.14	0.1.15	0.1.16	0.1.17	0.1.18	0.1.19	0.1.20	0.1.21
...
14.11.0	14.12.0	14.13.0	14.13.1	14.14.0	14.15.0	15.0.0	15.0.1
15.1.0
```



Installer une application:

```bash
~/Documents/nodeenv master* ⇡
❯ homebridge/bin/node -v
v14.15.0

# env obligatoire
~/Documents/nodeenv master* ⇡
❯ nodeenv --node=14.15.0 env

~/Documents/nodeenv master* ⇡
❯ cd homebridge/bin

~/Documents/nodeenv master* ⇡
❯ env/bin/npm install -g --unsafe-perm homebridge
/Users/bruno/Documents/nodeenv/env/bin/homebridge -> /Users/bruno/Documents/nodeenv/env/lib/node_modules/homebridge/bin/homebridge
+ homebridge@1.1.6
added 78 packages from 78 contributors in 5.065s

~/Documents/nodeenv master* ⇡
❯ env/bin/npm install -g --unsafe-perm homebridge-config-ui-x
/Users/bruno/Documents/nodeenv/env/bin/hb-service -> /Users/bruno/Documents/nodeenv/env/lib/node_modules/homebridge-config-ui-x/dist/bin/hb-service.js
/Users/bruno/Documents/nodeenv/env/bin/homebridge-config-ui-x -> /Users/bruno/Documents/nodeenv/env/lib/node_modules/homebridge-config-ui-x/dist/bin/standalone.js

```

