Aktuelle npm-Paketversion ermitteln

English Deutsch

Verwenden

npm_info_cmd.sh
npm info [package name] version | head -n1

um nur die aktuelle Paketversion auszugeben, zum Beispiel:

npm_info_example.sh
npm info @angular/cli version | head -n1

Der head -n1-Teil ist erforderlich, um unerwünschte npm-Info-Meldungen zu unterdrücken. Wenn der Befehl ohne head -n1 ausgeführt wird:

npm_info_full.sh
npm info @angular/cli version

wird folgende Ausgabe ausgegeben:

npm_info_output.txt
12.2.6
npm notice
npm notice New minor version of npm available! 7.21.1 -> 7.24.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.24.0
npm notice Run npm install -g [email protected] to update!
npm notice

Normalerweise wird der node:latest-Docker-Container anstelle eines lokalen npm verwendet, um die aktuelle Version eines npm-Pakets zu finden:

docker_npm_command.sh
docker run -it --rm node:latest npm info meshcommander version | head -n1

Zum Zeitpunkt der Artikelerstellung gibt der Befehl

npm_version_output.txt
0.9.0-d

Check out similar posts by category: NodeJS