0

I'm trying to develop a script to automate the installation of some programs and also the development environment. So I thought Chocolatey could help me with that.

How can I create a script to be run in the power shell to install chooclaty and then other applications?

It would be a script to run something like this:

# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

#After finish Chocolatey, run the commands:

# install apps
choco install vscode, git, nvm --force -n

# using nvm to install node version
nvm install v14.17.1
nvm use 14.17.1

# install yarn
npm install --global yarn

#install expo
npm install --global expo

Any idea how to do this? I would also improve the script to clone the repository, install dependencies with yarn, etc.

V. Gianvechio
  • 17
  • 1
  • 6
  • Can you tell me what about your code is not working? – Kevin Holtkamp May 30 '22 at 18:42
  • I get the message "npm is not recognized as an internal command". But I installed node in previous commands. Would it be possible to give a refreh in cmd or else close and open again calling the npm installations? – V. Gianvechio May 31 '22 at 04:27

1 Answers1

1

You could launch your later commands in a new powershell instance like this:

start powershell {npm install --global yarn; npm install --global expo}

For reference, you can find multiple different ways to do this with different options, depending on your future requirements, here.

Kevin Holtkamp
  • 479
  • 4
  • 17