kandi background
Explore Kits

nvm | Node Version Manager - POSIX-compliant bash script | Runtime Evironment library

 by   nvm-sh Shell Version: v0.38.0 License: MIT

 by   nvm-sh Shell Version: v0.38.0 License: MIT

Download this library from

kandi X-RAY | nvm Summary

nvm is a Shell library typically used in Server, Runtime Evironment, Nodejs, NPM applications. nvm has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • nvm has a medium active ecosystem.
  • It has 51095 star(s) with 5244 fork(s). There are 919 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 265 open issues and 1358 have been closed. On average issues are closed in 15 days. There are 71 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of nvm is v0.38.0
nvm Support
Best in #Runtime Evironment
Average in #Runtime Evironment
nvm Support
Best in #Runtime Evironment
Average in #Runtime Evironment

quality kandi Quality

  • nvm has 0 bugs and 0 code smells.
nvm Quality
Best in #Runtime Evironment
Average in #Runtime Evironment
nvm Quality
Best in #Runtime Evironment
Average in #Runtime Evironment

securitySecurity

  • nvm has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • nvm code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
nvm Security
Best in #Runtime Evironment
Average in #Runtime Evironment
nvm Security
Best in #Runtime Evironment
Average in #Runtime Evironment

license License

  • nvm is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
nvm License
Best in #Runtime Evironment
Average in #Runtime Evironment
nvm License
Best in #Runtime Evironment
Average in #Runtime Evironment

buildReuse

  • nvm releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
nvm Reuse
Best in #Runtime Evironment
Average in #Runtime Evironment
nvm Reuse
Best in #Runtime Evironment
Average in #Runtime Evironment
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

nvm Key Features

If you want to use the system-installed version of node, you can use the special default alias "system":.

nvm Examples and Code Snippets

See all related Code Snippets

Install & Update Script

copy iconCopydownload iconDownload
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Verify Installation

copy iconCopydownload iconDownload
command -v nvm

Git Install

copy iconCopydownload iconDownload
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Manual Install

copy iconCopydownload iconDownload
export NVM_DIR="$HOME/.nvm" && (
  git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
  cd "$NVM_DIR"
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

Manual Upgrade

copy iconCopydownload iconDownload
(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

Usage

copy iconCopydownload iconDownload
nvm install node # "node" is an alias for the latest version

Long-term Support

copy iconCopydownload iconDownload
nvm install 'lts/*' --reinstall-packages-from=current

Migrating Global Packages While Installing

copy iconCopydownload iconDownload
nvm install node --reinstall-packages-from=node

Default Global Packages From File While Installing

copy iconCopydownload iconDownload
# $NVM_DIR/default-packages

rimraf
object-inspect@1.0.2
stevemao/left-pad

io.js

copy iconCopydownload iconDownload
nvm install iojs

System Version of Node

copy iconCopydownload iconDownload
nvm use system
nvm run system --version

Listing Versions

copy iconCopydownload iconDownload
nvm ls

Setting Custom Colors

copy iconCopydownload iconDownload
r/R = red / bold red

g/G = green / bold green

b/B = blue / bold blue

c/C = cyan / bold cyan

m/M = magenta / bold magenta

y/Y = yellow / bold yellow

k/K = black / bold black

e/W = light grey / white

.nvmrc

copy iconCopydownload iconDownload
$ echo "5.9" > .nvmrc

$ echo "lts/*" > .nvmrc # to default to the latest LTS version

$ echo "node" > .nvmrc # to default to the latest version

Deeper Shell Integration

copy iconCopydownload iconDownload
cdnvm() {
    cd "$@";
    nvm_path=$(nvm_find_up .nvmrc | tr -d '\n')

    # If there are no .nvmrc file, use the default nvm version
    if [[ ! $nvm_path = *[^[:space:]]* ]]; then

        declare default_version;
        default_version=$(nvm version default);

        # If there is no default version, set it to `node`
        # This will use the latest version on your machine
        if [[ $default_version == "N/A" ]]; then
            nvm alias default node;
            default_version=$(nvm version default);
        fi

        # If the current version is not the default version, set it to use the default version
        if [[ $(nvm current) != "$default_version" ]]; then
            nvm use default;
        fi

        elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then
        declare nvm_version
        nvm_version=$(<"$nvm_path"/.nvmrc)

        declare locally_resolved_nvm_version
        # `nvm ls` will check all locally-available versions
        # If there are multiple matching versions, take the latest one
        # Remove the `->` and `*` characters and spaces
        # `locally_resolved_nvm_version` will be `N/A` if no local versions are found
        locally_resolved_nvm_version=$(nvm ls --no-colors "$nvm_version" | tail -1 | tr -d '\->*' | tr -d '[:space:]')

        # If it is not already installed, install it
        # `nvm install` will implicitly use the newly-installed version
        if [[ "$locally_resolved_nvm_version" == "N/A" ]]; then
            nvm install "$nvm_version";
        elif [[ $(nvm current) != "$locally_resolved_nvm_version" ]]; then
            nvm use "$nvm_version";
        fi
    fi
}
alias cd='cdnvm'
cd $PWD

Running Tests

copy iconCopydownload iconDownload
npm install

Bash Completion

copy iconCopydownload iconDownload
[[ -r $NVM_DIR/bash_completion ]] && \. $NVM_DIR/bash_completion

Usage

copy iconCopydownload iconDownload
alias               deactivate          install             list-remote         reinstall-packages  uninstall           version
cache               exec                install-latest-npm  ls                  run                 unload              version-remote
current             help                list                ls-remote           unalias             use                 which

Compatibility Issues

copy iconCopydownload iconDownload
prefix='some/path'

Installing nvm on Alpine Linux

copy iconCopydownload iconDownload
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Manual Uninstall

copy iconCopydownload iconDownload
$ rm -rf "$NVM_DIR"

Docker For Development Environment

copy iconCopydownload iconDownload
$ docker build -t nvm-dev .

Problems

copy iconCopydownload iconDownload
nvm install -s 0.8.6

macOS Troubleshooting

copy iconCopydownload iconDownload
sudo chmod ugo-x /usr/libexec/path_helper

ng --version showing The current version of Node (16.8.0) is not supported by Angular

copy iconCopydownload iconDownload
nvm use <previous-version>
npm uninstall -g @angular/cli
nvm use 16
npm install -g @angular/cli
ng version

zsh: bad CPU type in executable: node

copy iconCopydownload iconDownload
softwareupdate --install-rosetta

CircleCI: Use nodejs version 12

copy iconCopydownload iconDownload
jobs:
  build:
    docker:
      - image: cimg/node:12.16

Unable to downgrade Node.js using nvm on Windows

copy iconCopydownload iconDownload
C:\Program Files\nodejs\node.exe

NPM Error &quot;Can't find Python executable&quot; in MacOS Big Sur

copy iconCopydownload iconDownload
export PATH=/usr/bin/python:$PATH
export PYTHON=/usr/bin/python
export PATH=/usr/bin/python:$PATH
export PYTHON=/usr/bin/python
$ export npm_config_python=/path/to/python
$ npm config list
...

; environment configs
python = "/path/to/python"
python = "/path/to/python"
npm config --global set python /path/to/python
$ export npm_config_python=/path/to/python
$ npm config list
...

; environment configs
python = "/path/to/python"
python = "/path/to/python"
npm config --global set python /path/to/python
$ export npm_config_python=/path/to/python
$ npm config list
...

; environment configs
python = "/path/to/python"
python = "/path/to/python"
npm config --global set python /path/to/python
$ export npm_config_python=/path/to/python
$ npm config list
...

; environment configs
python = "/path/to/python"
python = "/path/to/python"
npm config --global set python /path/to/python

Rails bundle install Could not find turbo-rails-7.1.1 in any of the sources

copy iconCopydownload iconDownload
gem 'turbo-rails', '~> 0.8'

Why is systemd service giving an error on start

copy iconCopydownload iconDownload
ExecStart=/root/.nvm/versions/node/v16.6.1/bin/node node_modules/directus/dist/start.js

How do I connect to MongoDB, running in Github codespaces, using MongoDB Compass?

copy iconCopydownload iconDownload
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862
ssh -R 27017:localhost:27017 your_public_ip
mongodb://localhost:27017
mongodb://localhost:27017
npm i ngrok --save-dev
./node_modules/.bin/ngrok authtoken <the token>
./node_modules/.bin/ngrok tcp 27017
mongodb://0.tcp.ngrok.io:18862

Run multiple Google Apps Script clasp commands in parallel using a Bash script

copy iconCopydownload iconDownload
{ 
    while IFS= read -d $'\0' -ru $find file; do
        (
            cd "$(dirname "$file")"
            project_dir_name="$(basename "$(pwd)")"
            echo "Pulling project ($project_dir_name)"
            if clasp pull </dev/null 2>&1 ;then
                printf '\nExeClaspResult: %s Success\n' "$project_dir_name"
            else
                printf '\nExeClaspResult: %s Failed\n' "$project_dir_name"
            fi
        ) &
    done {find}< <(find . -name '.clasp.json' -print0)
    wait
} |
    sed -une 's/^ExeClaspResult: //p'
{ 
    while IFS= read -d $'\0' -ru $find file; do
        (
            cd "$(dirname "$file")"
            project_dir_name="$(basename "$(pwd)")"
            echo "Pulling project ($project_dir_name)"
            if clasp pull </dev/null > >(
                  sed "s/^/OUT $project_dir_name: /") 2> >(
                  sed "s/^/ERR $project_dir_name: /"
                );then
                printf '\nExeClaspResult: %s Success\n' "$project_dir_name"
            else
                printf '\nExeClaspResult: %s Failed\n' "$project_dir_name"
            fi
        ) &
    done {find}< <(find . -name '.clasp.json' -print0)
    wait
} |
    sed -ue '
        s/^ExeClaspResult: \(.* Failed\)$/\o33[31m** \1 **\o33[0m/;
        s/^ExeClaspResult: \(.*\)$/\o33[32m** \1 **\o33[0m/;'
{ 
    while IFS= read -d $'\0' -ru $find file; do
        (
            cd "$(dirname "$file")"
            project_dir_name="$(basename "$(pwd)")"
            echo "Pulling project ($project_dir_name)"
            if clasp pull </dev/null 2>&1 ;then
                printf '\nExeClaspResult: %s Success\n' "$project_dir_name"
            else
                printf '\nExeClaspResult: %s Failed\n' "$project_dir_name"
            fi
        ) &
    done {find}< <(find . -name '.clasp.json' -print0)
    wait
} |
    sed -une 's/^ExeClaspResult: //p'
{ 
    while IFS= read -d $'\0' -ru $find file; do
        (
            cd "$(dirname "$file")"
            project_dir_name="$(basename "$(pwd)")"
            echo "Pulling project ($project_dir_name)"
            if clasp pull </dev/null > >(
                  sed "s/^/OUT $project_dir_name: /") 2> >(
                  sed "s/^/ERR $project_dir_name: /"
                );then
                printf '\nExeClaspResult: %s Success\n' "$project_dir_name"
            else
                printf '\nExeClaspResult: %s Failed\n' "$project_dir_name"
            fi
        ) &
    done {find}< <(find . -name '.clasp.json' -print0)
    wait
} |
    sed -ue '
        s/^ExeClaspResult: \(.* Failed\)$/\o33[31m** \1 **\o33[0m/;
        s/^ExeClaspResult: \(.*\)$/\o33[32m** \1 **\o33[0m/;'
#!/usr/bin/env bash

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# Check and process command line
if (( $# < 1 )); then
    echo "Usage: $(basename "$0") ACTION [ARG]..."
    exit 2
fi
action="$1"
args=("${@:2}")

# Define cleanup handler, create temporary log directory
trap '[[ -n "$(jobs -p)" ]] && kill -- -$$; [[ -n "${logdir}" ]] && rm -rf "${logdir}"' EXIT
logdir=$(mktemp -d)

# Start specified action for each project
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done

# Wait for background jobs to finish and report results
echo -e "\nWaiting for background jobs to finish...\n"
jobs_done=0; jobs_total=${#files[@]}
while true; do
    wait -n -p pid; result=$?
    [[ -z "${pid}" ]] && break
    jobs_done=$((jobs_done + 1))
    if (( ${result} == 0 )); then
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;32mSUCCESS\e[0m"
    else
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;31mFAILURE\e[0m"
        cat "${pid_log_map[${pid}]}"
    fi
done
readarray -t files < <(find . -name '.clasp.json' | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file#'./'}")
# Start specified action for each project
max_jobs=25; poll_delay="0.1s"
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    if (( ${max_jobs} > 0 )); then
        while jobs=$(jobs -r -p | wc -l) && (( ${jobs} >= ${max_jobs} )); do
            sleep "${poll_delay}"
        done
    fi
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done
( cd "${project}" && exec clasp "${action}" "${args[@]}" ) &>"${logfile}" &
#!/usr/bin/env bash

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# Check and process command line
if (( $# < 1 )); then
    echo "Usage: $(basename "$0") ACTION [ARG]..."
    exit 2
fi
action="$1"
args=("${@:2}")

# Define cleanup handler, create temporary log directory
trap '[[ -n "$(jobs -p)" ]] && kill -- -$$; [[ -n "${logdir}" ]] && rm -rf "${logdir}"' EXIT
logdir=$(mktemp -d)

# Start specified action for each project
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done

# Wait for background jobs to finish and report results
echo -e "\nWaiting for background jobs to finish...\n"
jobs_done=0; jobs_total=${#files[@]}
while true; do
    wait -n -p pid; result=$?
    [[ -z "${pid}" ]] && break
    jobs_done=$((jobs_done + 1))
    if (( ${result} == 0 )); then
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;32mSUCCESS\e[0m"
    else
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;31mFAILURE\e[0m"
        cat "${pid_log_map[${pid}]}"
    fi
done
readarray -t files < <(find . -name '.clasp.json' | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file#'./'}")
# Start specified action for each project
max_jobs=25; poll_delay="0.1s"
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    if (( ${max_jobs} > 0 )); then
        while jobs=$(jobs -r -p | wc -l) && (( ${jobs} >= ${max_jobs} )); do
            sleep "${poll_delay}"
        done
    fi
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done
( cd "${project}" && exec clasp "${action}" "${args[@]}" ) &>"${logfile}" &
#!/usr/bin/env bash

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# Check and process command line
if (( $# < 1 )); then
    echo "Usage: $(basename "$0") ACTION [ARG]..."
    exit 2
fi
action="$1"
args=("${@:2}")

# Define cleanup handler, create temporary log directory
trap '[[ -n "$(jobs -p)" ]] && kill -- -$$; [[ -n "${logdir}" ]] && rm -rf "${logdir}"' EXIT
logdir=$(mktemp -d)

# Start specified action for each project
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done

# Wait for background jobs to finish and report results
echo -e "\nWaiting for background jobs to finish...\n"
jobs_done=0; jobs_total=${#files[@]}
while true; do
    wait -n -p pid; result=$?
    [[ -z "${pid}" ]] && break
    jobs_done=$((jobs_done + 1))
    if (( ${result} == 0 )); then
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;32mSUCCESS\e[0m"
    else
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;31mFAILURE\e[0m"
        cat "${pid_log_map[${pid}]}"
    fi
done
readarray -t files < <(find . -name '.clasp.json' | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file#'./'}")
# Start specified action for each project
max_jobs=25; poll_delay="0.1s"
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    if (( ${max_jobs} > 0 )); then
        while jobs=$(jobs -r -p | wc -l) && (( ${jobs} >= ${max_jobs} )); do
            sleep "${poll_delay}"
        done
    fi
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done
( cd "${project}" && exec clasp "${action}" "${args[@]}" ) &>"${logfile}" &
#!/usr/bin/env bash

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# Check and process command line
if (( $# < 1 )); then
    echo "Usage: $(basename "$0") ACTION [ARG]..."
    exit 2
fi
action="$1"
args=("${@:2}")

# Define cleanup handler, create temporary log directory
trap '[[ -n "$(jobs -p)" ]] && kill -- -$$; [[ -n "${logdir}" ]] && rm -rf "${logdir}"' EXIT
logdir=$(mktemp -d)

# Start specified action for each project
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done

# Wait for background jobs to finish and report results
echo -e "\nWaiting for background jobs to finish...\n"
jobs_done=0; jobs_total=${#files[@]}
while true; do
    wait -n -p pid; result=$?
    [[ -z "${pid}" ]] && break
    jobs_done=$((jobs_done + 1))
    if (( ${result} == 0 )); then
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;32mSUCCESS\e[0m"
    else
        echo -e "Action '\e[1m${action}\e[0m' for project '\e[1m${pid_pro_map[${pid}]}\e[0m' (pid ${pid}) (${jobs_done}/${jobs_total}): \e[1;31mFAILURE\e[0m"
        cat "${pid_log_map[${pid}]}"
    fi
done
readarray -t files < <(find . -name '.clasp.json' | sort -V)
for file in "${files[@]}"; do
    project=$(dirname "${file#'./'}")
# Start specified action for each project
max_jobs=25; poll_delay="0.1s"
declare -A pid_pro_map=() pid_log_map=()
readarray -t files < <(find . -name '.clasp.json' -printf "%P\n" | sort -V)
for file in "${files[@]}"; do
    if (( ${max_jobs} > 0 )); then
        while jobs=$(jobs -r -p | wc -l) && (( ${jobs} >= ${max_jobs} )); do
            sleep "${poll_delay}"
        done
    fi
    project=$(dirname "${file}")
    logfile=$(mktemp -p "${logdir}")
    ( cd "${project}" && clasp "${action}" "${args[@]}" ) &>"${logfile}" &
    pid=$!; pid_pro_map[${pid}]="${project}"; pid_log_map[${pid}]="${logfile}"
    echo -e "Started action '\e[1m${action}\e[0m' for project '\e[1m${project}\e[0m' (pid ${pid})"
done
( cd "${project}" && exec clasp "${action}" "${args[@]}" ) &>"${logfile}" &
#!/bin/bash

cleanup () {
    exec 3>&-
    exec 4>&-

    rm .pull-all-log.fifo .pull-all-log-err.fifo

    kill $(jobs -p)
    kill -9 $(jobs -p) &>/dev/null
}

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[[ -s "/usr/local/opt/nvm/nvm.sh" ]] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# you can use /tmp or mktemp -u if you're worried about clobbering
rm -f .pull-all-log.fifo .pull-all-log-err.fifo
mkfifo .pull-all-log.fifo .pull-all-log-err.fifo
trap cleanup EXIT

exec 3<> .pull-all-log.fifo
exec 4<> .pull-all-log-err.fifo

for file in ./*/.clasp.json; do
    [[ -d "$file" ]] && continue

    parent=$(dirname "$file")
    proj=${parent##*/}

    echo "Pulling $proj..."

    {
        cd "$parent"

        if clasp pull &>/dev/null; then
            echo "Pulling $proj succeeded" >&3
        else
            echo "Pulling $proj FAILED" >&4
        fi
    } &
done

running_pids=$(jobs -p)

cat <&3 &
cat <&4 >&2 &

[[ "$running_pids" ]] && wait $running_pids
Pulling project-1...
Pulling project-2...
Pulling project-3...
Pulling project-4...
Pulling project-5...
Pulling project-6...
Pulling project-7...
Pulling project-8...
Pulling project-9...
Pulling project-1 succeeded
Pulling project-9 succeeded
Pulling project-3 succeeded
Pulling project-4 FAILED
Pulling project-5 succeeded
Pulling project-2 succeeded
Pulling project-6 FAILED
Pulling project-7 FAILED
Pulling project-8 FAILED
#!/bin/bash

cleanup () {
    exec 3>&-
    exec 4>&-

    rm .pull-all-log.fifo .pull-all-log-err.fifo

    kill $(jobs -p)
    kill -9 $(jobs -p) &>/dev/null
}

# use Node 14.17.5 to prevent "Error: Looks like you are offline." errors
# (see https://github.com/google/clasp/issues/872)
[[ -s "/usr/local/opt/nvm/nvm.sh" ]] && . "/usr/local/opt/nvm/nvm.sh"
nvm install 14.17.5
nvm use 14.17.5

# you can use /tmp or mktemp -u if you're worried about clobbering
rm -f .pull-all-log.fifo .pull-all-log-err.fifo
mkfifo .pull-all-log.fifo .pull-all-log-err.fifo
trap cleanup EXIT

exec 3<> .pull-all-log.fifo
exec 4<> .pull-all-log-err.fifo

for file in ./*/.clasp.json; do
    [[ -d "$file" ]] && continue

    parent=$(dirname "$file")
    proj=${parent##*/}

    echo "Pulling $proj..."

    {
        cd "$parent"

        if clasp pull &>/dev/null; then
            echo "Pulling $proj succeeded" >&3
        else
            echo "Pulling $proj FAILED" >&4
        fi
    } &
done

running_pids=$(jobs -p)

cat <&3 &
cat <&4 >&2 &

[[ "$running_pids" ]] && wait $running_pids
Pulling project-1...
Pulling project-2...
Pulling project-3...
Pulling project-4...
Pulling project-5...
Pulling project-6...
Pulling project-7...
Pulling project-8...
Pulling project-9...
Pulling project-1 succeeded
Pulling project-9 succeeded
Pulling project-3 succeeded
Pulling project-4 FAILED
Pulling project-5 succeeded
Pulling project-2 succeeded
Pulling project-6 FAILED
Pulling project-7 FAILED
Pulling project-8 FAILED
parallel -j100 --tag 'cd {//} && clasp pull || echo Fail' ::: */.clasp.json
parallel -j100 --tag 'cd {//} && neno clasp pull || echo Fail' ::: */.clasp.json
parallel -j100 --tag 'cd {//} && clasp pull || echo Fail' ::: */.clasp.json
parallel -j100 --tag 'cd {//} && neno clasp pull || echo Fail' ::: */.clasp.json

Solidity Time-Travel Test Failing

copy iconCopydownload iconDownload
// no callback, fails
await web3.currentProvider.send({
    jsonrpc: "2.0",
    method: "evm_increaseTime",
    params: [duration],
    id: new Date().getTime()
});
async function increase(duration) {
    return new Promise((resolve, reject) => {
        web3.currentProvider.send({
            jsonrpc: "2.0",
            method: "evm_increaseTime",
            params: [duration],
            id: new Date().getTime()
        }, (err, result) => {
            // second call within the callback
            web3.currentProvider.send({
                jsonrpc: '2.0',
                method: 'evm_mine',
                params: [],
                id: new Date().getTime()
            }, (err, result) => {
                // need to resolve the Promise in the second callback
                resolve();
            });
        });
    });
}
// no callback, fails
await web3.currentProvider.send({
    jsonrpc: "2.0",
    method: "evm_increaseTime",
    params: [duration],
    id: new Date().getTime()
});
async function increase(duration) {
    return new Promise((resolve, reject) => {
        web3.currentProvider.send({
            jsonrpc: "2.0",
            method: "evm_increaseTime",
            params: [duration],
            id: new Date().getTime()
        }, (err, result) => {
            // second call within the callback
            web3.currentProvider.send({
                jsonrpc: '2.0',
                method: 'evm_mine',
                params: [],
                id: new Date().getTime()
            }, (err, result) => {
                // need to resolve the Promise in the second callback
                resolve();
            });
        });
    });
}

See all related Code Snippets

Community Discussions

Trending Discussions on nvm
  • Z_DATA_ERROR, ERRNO -3, zlib: incorrect data check, MBA M1
  • Unexpected token '.' when run create-react-app
  • ng --version showing The current version of Node (16.8.0) is not supported by Angular
  • when i use vscode extension Remote-ssh to connect to my remote server, i found vs cannot install vscoe-server in host
  • zsh: bad CPU type in executable: node
  • CircleCI: Use nodejs version 12
  • Node and npm not found after restarting macOS
  • Unable to downgrade Node.js using nvm on Windows
  • Android Studio can't run AVD... times out
  • NPM Error &quot;Can't find Python executable&quot; in MacOS Big Sur
Trending Discussions on nvm

QUESTION

Z_DATA_ERROR, ERRNO -3, zlib: incorrect data check, MBA M1

Asked 2022-Mar-17 at 00:11

Recently I face an issues to install my dependencies using latest Node and NPM on my MacBook Air M1 machine. Then I found out M1 is not supported latest Node version. So my solution, to using NVM and change them to Node v14.16

Everything works well, but when our team apply new eslint configuration. Yet, I still not sure whether eslint was causes the error or not.

.eslintrc
{
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "extends": ["eslint:recommended", "plugin:react/recommended"],
  "parser": "@babel/eslint-parser",
  "parserOptions": {
    "requireConfigFile": false,
    "ecmaVersion": 2018,
    "sourceType": "module",
    "ecmaFeatures": {
      "impliedStrict": true,
      "jsx": true
    }
  },
  "plugins": ["react", "prettier", "@babel"],
  "rules": {
    // "prettier/prettier": [
    //   "warn",
    //   {
    //     "endOfLine": "auto",
    //   }
    // ],
    "no-console": 1,
    "indent": [
      2,
      2,
      {
        "SwitchCase": 1
      }
    ],
    "linebreak-style": 0,
    "quotes": [2, "single"],
    "semi": 0,
    "curly": [2, "all"],
    "camelcase": "off",
    "react/display-name": "off",
    "eqeqeq": [2, "smart"],
    "one-var-declaration-per-line": [2, "always"],
    "new-cap": 2,
    "no-case-declarations": 0
  },
  "globals": {
    "axios": true,
    "PropTypes": true
  },
  "settings": {
    "import/resolver": {
      "alias": [["./src/"]]
    }
  }
}

This error was occurred:

Error
npm ERR! code Z_DATA_ERROR
npm ERR! errno -3
npm ERR! zlib: incorrect data check
Log
5147 silly saveTree └── yup@0.32.11
5148 verbose stack ZlibError: zlib: incorrect data check
5148 verbose stack     at Unzip.write (/Users/metalheadcoder/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/minizlib/index.js:147:22)
5148 verbose stack     at Object.write (/Users/metalheadcoder/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:305:58)
5148 verbose stack     at PassThrough.ondata (internal/streams/readable.js:719:22)
5148 verbose stack     at PassThrough.emit (events.js:315:20)
5148 verbose stack     at addChunk (internal/streams/readable.js:309:12)
5148 verbose stack     at readableAddChunk (internal/streams/readable.js:284:9)
5148 verbose stack     at PassThrough.Readable.push (internal/streams/readable.js:223:10)
5148 verbose stack     at PassThrough.Transform.push (internal/streams/transform.js:166:32)
5148 verbose stack     at PassThrough.afterTransform (internal/streams/transform.js:101:10)
5148 verbose stack     at PassThrough._transform (internal/streams/passthrough.js:46:3)
5148 verbose stack     at PassThrough.Transform._read (internal/streams/transform.js:205:10)
5148 verbose stack     at PassThrough.Transform._write (internal/streams/transform.js:193:12)
5148 verbose stack     at writeOrBuffer (internal/streams/writable.js:358:12)
5148 verbose stack     at PassThrough.Writable.write (internal/streams/writable.js:303:10)
5148 verbose stack     at Readable.ondata (internal/streams/readable.js:719:22)
5148 verbose stack     at Readable.emit (events.js:315:20)
5149 verbose cwd /Users/metalheadcoder/Gitlab/warefe
5150 verbose Darwin 21.1.0
5151 verbose argv "/Users/metalheadcoder/.nvm/versions/node/v14.16.1/bin/node" "/Users/metalheadcoder/.nvm/versions/node/v14.16.1/bin/npm" "install"
5152 verbose node v14.16.1
5153 verbose npm  v6.14.12
5154 error code Z_DATA_ERROR
5155 error errno -3
5156 error zlib: incorrect data check
5157 verbose exit [ -3, true ]
Machine

MacBookAir M1 2020

Approach
  • Install package using nvm use v14
  • Install package using nvm use v16
  • Install package using nvm use v17
  • Remove node_modules and package-lock.js also run npm cache clean --force

Thank you in advance.

ANSWER

Answered 2022-Mar-17 at 00:11

I had a similar problem with another module.

The solution I found was to update both node (to v16) and npm (to v8).

For Node, I used brew (but nvm should be OK).

For npm, I used what the official doc says :

npm install -g npm@latest

Source https://stackoverflow.com/questions/69793334

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install nvm

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:. Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
If the environment variable $XDG_CONFIG_HOME is present, it will place the nvm files there.
You can add --no-use to the end of the above script (...nvm.sh --no-use) to postpone using nvm until you manually use it.
You can customize the install source, directory, profile, and version using the NVM_SOURCE, NVM_DIR, PROFILE, and NODE_VERSION variables. Eg: curl ... | NVM_DIR="path/to/nvm". Ensure that the NVM_DIR does not contain a trailing slash.
The installer can use git, curl, or wget to download nvm, whichever is available.
Since macOS 10.15, the default shell is zsh and nvm will look for .zshrc to update, none is installed by default. Create one with touch ~/.zshrc and run the install script again.
If you use bash, the previous default shell, your system may not have a .bash_profile file where the command is set up. Create one with touch ~/.bash_profile and run the install script again. Then, run source ~/.bash_profile to pick up the nvm command.
You have previously used bash, but you have zsh installed. You need to manually add these lines to ~/.zshrc and run . ~/.zshrc.
You might need to restart your terminal instance or run . ~/.nvm/nvm.sh. Restarting your terminal/opening a new tab/window, or running the source command will load the command and the new configuration.
If the above didn't help, you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
If you use bash, it may be that your .bash_profile (or ~/.profile) does not source your ~/.bashrc properly. You could fix this by adding source ~/<your_profile_file> to it or follow the next step below.
Try adding the snippet from the install section, that finds the correct nvm directory and loads nvm, to your usual profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
For more information about this issue and possible workarounds, please refer here
To verify that nvm has been installed, do:. which should output nvm if the installation was successful. Please note that which nvm will not work, since nvm is a sourced shell function, not an executable binary.
If you have git installed (requires git v1.7.10+):. Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files).
clone this repo in the root of your user profile
cd ~/ from anywhere then git clone https://github.com/nvm-sh/nvm.git .nvm
cd ~/.nvm and check out the latest version with git checkout v0.38.0
activate nvm by sourcing it from your shell: . ./nvm.sh
For a fully manual install, execute the following lines to first clone the nvm repository into $HOME/.nvm, and then load nvm:. Now add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files).
For manual upgrade with git (requires git v1.7.10+):.
change to the $NVM_DIR
pull down the latest changes
check out the latest version
activate the new version

Support

Node has a schedule for long-term support (LTS) You can reference LTS versions in aliases and .nvmrc files with the notation lts/* for the latest LTS, and lts/argon for LTS releases from the "argon" line, for example. In addition, the following commands support LTS arguments:. Any time your local copy of nvm connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under $NVM_DIR/alias/lts), are managed by nvm, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported. To get the latest LTS version of node and migrate your existing installed packages, use.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Share this Page

share link
Consider Popular Runtime Evironment Libraries
Compare Runtime Evironment Libraries with Highest Support
Compare Runtime Evironment Libraries with Highest Quality
Compare Runtime Evironment Libraries with Highest Security
Compare Runtime Evironment Libraries with Permissive License
Compare Runtime Evironment Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.