0

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?

1 Answer 1

1

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 }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.