Reputation: 261
i want to run npm command in each folder
Get-ChildItem -Directory -Filter "desiredFolder" | ForEach-Object {&npm install}
Problem i am experiencing is that npm command runs from root folder where is script not from each folder from foreach. How can I fix it?
Upvotes: 0
Views: 408
Reputation: 174485
Use Push-Location
/Pop-Location
to drop in and out of the directory while installing:
Get-ChildItem -Directory -Filter "desiredFolder" | ForEach-Object { $_ |Push-Location; try{ &npm install }finally{ Pop-Location }}
Upvotes: 1