Socket
Socket
Sign inDemoInstall

pwsh

Package Overview
Dependencies
9
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pwsh

Install PowerShell Core via npm, allowing you to use it in npm scripts and node projects.


Version published
Maintainers
1
Install size
4.84 MB
Created

Changelog

Source

v0.3.0

  • Move tests from Pester to mocha
  • Move from TravisCI to Github Actions
  • Tweak publishing workflow
  • Improve version parsing script to pull and parse all releases from Github's API.
  • Add many more pwsh versions
  • Add arm and arm64 pwsh packages

Readme

Source

pwsh

Install PowerShell Core via npm, allowing you to use it in npm scripts and node projects.

npm i -g pwsh may be the easiest way to get started with PowerShell Core on any platform.

Why?

I prefer PowerShell to bash for quickly writing npm scripts. (opinion) However, I can't expect collaborators to have it installed.* Adding "pwsh" as a "devDependency" solves that problem without any extra effort.

We support both global and local npm installations, and we use a shared cache to avoid downloading duplicate copies of the full pwsh distribution. This means you can install us as a local dev dependency in dozens of projects, and the installation process will quickly create a symlink to the cache.

* Even on Windows, the aging "Windows PowerShell" is preinstalled but we want to use pwsh / PowerShell Core, the cross-platform, more up-to-date edition of PowerShell.

Usage

If you just want to use pwsh for your npm scripts, add us as a devDependency:

npm install --save-dev pwsh

If you want pwsh to be globally available as an interactive shell:

npm install --global pwsh

All installations are shared, so you can depend on "pwsh" in many projects without downloading multiple copies of pwsh. See the FAQ for details.

Example

// Example package.json
{
    "devDependencies": {
        // Use the latest pwsh to install pwsh 6.0.4
        "pwsh": "pwsh6.0.4"
    },
    "scripts": {
        "test": "pwsh -NoProfile ./scripts/test.ps1"
    }
}

FAQ

Where is PowerShell installed?

--global installations go into your npm prefix:

  • Linux and Mac: "<npm prefix>/lib/node_modules/@cspotcode/pwsh-cache"
  • Windows: "<npm prefix>/node_modules/@cspotcode/pwsh-cache"

Local installations are cached in "$HOME/.npm-pwsh". We use your $HOME directory because Linux and Mac, by default, require root for global installations, so the npm prefix isn't writable.

Installation is merely extracting the .zip or .tar.gz download from PowerShell Core's Github releases. No scripts are run; your system is not modified.

# To view globally installed versions on Linux and Mac
cd "$(npm get prefix)/lib/node_modules/@cspotcode/pwsh-cache"
ls # shows all the versions installed

Installations are cached and shared, so if you work on 5 different projects that all depend on "pwsh", only a single copy of pwsh will be downloaded. Subsequent npm installs should be very fast, merely creating a symlink at "./node_modules/.bin/pwsh".

PowerShell Core is about 50MB to download; 127MB extracted.

How do I install a specific version of pwsh?

By default we install the latest version of PowerShell Core. To install a specific version -- including prereleases -- check the dist-tags and install the one you want.

npm install pwsh@pwsh6.2.0-preview.1

*Remember, npm dist-tags !== npm versions.

Dependencies

We are not running sudo apt-get, brew install, etc. So it's possible PowerShell will complain about unmet dependencies that we're unable to provide. For context, checkout out issue #8.

Keywords

FAQs

Last updated on 09 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc