0

Does anyone know how it works to run a script from the cmd shell which executes powershell, navigates to a location and execute npm?

actually 'powershell.exe -NoExit -Command Set-Location C:\workspaces\app\ui' works fine. But I couldn't handle it to run now "npm install" and after this is done "npm start". Could maybe someone helps me here?

best regards and thanks in advance! :) Andreas

  • 2
    Fyi, you should include the code you're using to try running the npm install. If we can see exactly what you're running it will help identity issues... For example, maybe you're using an unquoted path with spaces. – Chad Baldwin Nov 22 '21 at 07:30
  • 1
    It is important to understand that `npm` is really a batch file, `npm.cmd`. When you run for example `npm install …` and `npm start …` from a batch file, you are supposed to use the `call` command, in order that the second command will run upon completion of the first, and within the same environment as the first. If you run each as separate commands in PowerShell, the second would run in a different environment as the first, and you would therefore need to implement a method of maintaining that environment. See [this related post](https://stackoverflow.com/q/4384814), for how you may do that. – Compo Nov 22 '21 at 10:32
  • Does this answer your question? [How to run powershell script from .ps1 file?](https://stackoverflow.com/questions/58524451/how-to-run-powershell-script-from-ps1-file) – Tomerikoo Nov 23 '21 at 08:35

0 Answers0