-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnodejs.sh
More file actions
executable file
·44 lines (37 loc) · 935 Bytes
/
nodejs.sh
File metadata and controls
executable file
·44 lines (37 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#/bin/bash
export PATH="/usr/local/opt/node@14/bin:$PATH"
HOMEBREW_PATH="$(command -v brew)"
lazynvm() {
if typeset -f nvm > /dev/null; then unset -f nvm; fi
if typeset -f node > /dev/null; then unset -f node; fi
if typeset -f npm > /dev/null; then unset -f npm; fi
if typeset -f npx > /dev/null; then unset -f npx; fi
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
}
nvm() {
lazynvm
nvm $@
}
node() {
lazynvm
node $@
}
npm() {
lazynvm
npm $@
}
npx() {
lazynvm
npx $@
}
# Display npm prefix asynchronously to avoid blocking shell startup
(
if [ -s "$HOME/.nvm/nvm.sh" ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" --no-use 2>/dev/null
if command -v npm &> /dev/null; then
command npm config get prefix 2>/dev/null
fi
fi
) >/dev/null 2>&1 &!