`npm` innerhalb von einem bat-File braucht `call`, aber dann sieht man nur wie die 1 Zeile ausgeführt wird?

ruutaiokwu

Top Contributor
Hallo zusammen

Wenn ich in einem Windows-Batch kein `call` bei mehreren `npm`-Zeilen verwende, dann führt `npm` dazu dass nach der 1. npm-Zeile des batch-Files die Verarbeitung abgebrochen wird - die Stapelverarbeitung läuft also nicht mehr weiter.

(So nebenbei und meine persönliche Meinung zu diesem Kran: Wie behämmert ist denn sowas, WTF, dümmer könnte man es wohl nicht machen?!?)

Wenn ich vor jede `npm`-Zeile ein `call` reinmache, dann werden zwar alle Zeilen ausgeführt aber im Konsolenfenster sieht man nur den ersten Eintrag als `call npm ... ` :

Batch:
Code:
@echo on
call npm install cordova-plugin-build-architecture

call npm install -g @angular/cli
call npm install -g @ionic/cli
call npm install -g cordova
call npm install -g native-run


pause



Ausgabe:

Code:
C:\Users\user1\Desktop\GIT\qr-code-app>call npm install cordova-plugin-build-architecture
npm WARN karma-jasmine-html-reporter@1.5.1 requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\karma\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\@angular\compiler-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ cordova-plugin-build-architecture@1.0.6
updated 1 package and audited 19311 packages in 10.55s

26 packages are looking for funding
  run `npm fund` for details

found 79 vulnerabilities (78 low, 1 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\user1\AppData\Roaming\npm\ng -> C:\Users\user1\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

> @angular/cli@9.1.2 postinstall C:\Users\user1\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js

+ @angular/cli@9.1.2
updated 1 package in 7.536s
C:\Users\user1\AppData\Roaming\npm\ionic -> C:\Users\user1\AppData\Roaming\npm\node_modules\@ionic\cli\bin\ionic
+ @ionic/cli@6.6.0
updated 1 package in 4.402s
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\user1\AppData\Roaming\npm\cordova -> C:\Users\user1\AppData\Roaming\npm\node_modules\cordova\bin\cordova
+ cordova@9.0.0
updated 1 package in 8.639s
C:\Users\user1\AppData\Roaming\npm\native-run -> C:\Users\user1\AppData\Roaming\npm\node_modules\native-run\bin\native-run
+ native-run@1.0.0
updated 1 package in 0.986s
Drücken Sie eine beliebige Taste . . .


...vom einen Quatsch zum anderen könnte man da wohl problemlos sagen!

Vielleicht weiss jemand, was das Ganze soll und wie man es bewerkstelligt dass bei der Ausführung des batches angezeigt wird welche npm-Zile nun dran ist. (Wie normal, wenn man kein `call` verwendet in Kombination mit Befehlen welche zu keinem Abbruch führen...)

Vielen Dank.
 

M.L.

Top Contributor
Kann man auch die Windows Powershell benutzen ? Abgesehen davon kann man Packages bei npm auch kombinieren, siehe Screenshot von
Code:
 npm install -g @angular/cli cordova native-run
 

Anhänge

  • npm_Packages_Kombination.JPG
    npm_Packages_Kombination.JPG
    84,5 KB · Aufrufe: 4

ruutaiokwu

Top Contributor
Das Problem besteht bei der PowerShell bei VisualStudio Code ist schliesslich die PowerShell integrioert. Und dort tritt das so auf....
 

ruutaiokwu

Top Contributor
"Abgesehen davon kann man Packages bei npm auch kombinieren"

Ja das könnte man als Workaround nutzen, vielen Dank, aber meine Frage ist da eher genereller Natur...
 

ruutaiokwu

Top Contributor
Ja, gleiches Verhalten auch bei der "normalen" cmd-Konsole:


Code:
C:\Users\user1\Desktop\GIT\qr-code-app>call npm uninstall -g native-run removed 30 packages in 0.337s removed 434 packages in 3.468s removed 227 packages in 2.31s removed 272 packages in 2.813s npm WARN karma-jasmine-html-reporter@1.5.1 requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\webpack-dev-server\node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\karma\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\@angular\compiler-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

removed 1 package and audited 19310 packages in 9.232s

26 packages are looking for funding
  run `npm fund` for details

found 79 vulnerabilities (78 low, 1 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details Drücken Sie eine beliebige Taste . . .
 

ruutaiokwu

Top Contributor
So macht man das:

Code:
@echo off
REM Partially from https://stackoverflow.com/a/935681

set RESTVAR=%1
shift
:loop1
if "%1"=="" goto after_loop
set RESTVAR=%RESTVAR% %1
shift
goto loop1

:after_loop
echo %RESTVAR%
call %RESTVAR%


Vielen Dank an "Marco13" vom byte-welt-Forum:
 

Neue Themen


Oben