configure GitHub Actions to work with npm --global
GitHub Actions doesn't play nicely with npm install --global
without sudo
, nor does it allow it to be easily cached.
This Action will change npm's behavior to:
- use
npm install --global
withoutsudo
- change the global install path to
<path>/packages
- update the
$PATH
search path to include the new global npm install path for binary execution - change the npm cache path to
<path>/cache
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v2.1.4
with:
key: ${{ hashFiles('**/package-lock.json') }}
path: |
~/.my-npm-stuff
node_modules
- uses: ahmadnassri/action-npm-global-path@v1
with:
path: ~/.my-npm-stuff
input | required | default | description |
---|---|---|---|
path | ❌ | ~/.npm |
root path to use |
Author: Ahmad Nassri • Twitter: @AhmadNassri