Skip to content

Latest release fails because always-auth is not a valid npm option #66

Open
@jshields-squarespace

Description

@jshields-squarespace

Summary

The latest release of the plugins/npm Docker image (after #65) fails when trying to execute npm config set always-auth true, with the following error message:

npm ERR! `always-auth` is not a valid npm option

Cause

The Dockerfile for plugins/npm installs npm via RUN apk add --no-cache git nodejs npm. In the latest version of plugins/npm, this installs NPM version 9.1.2. In the previous release of plugins/npm, this was NPM version 8.1.3.

Sometime between NPM 8.1.3 and 9.1.2, setting the always-auth option must have become an error.

It appears that always-auth was removed in NPM 7.11.1 (changelog, pull request), but setting it as a config option didn't return an error until NPM 9.0.0-pre.6 (changelog, pull request).

Repro Steps

To reproduce:

echo '{"name": "foobar", "version": "1.0.0"}' >package.json

docker pull plugins/npm:latest

docker run --rm \
  -e NPM_USERNAME=drone \
  -e NPM_PASSWORD=password \
  -e [email protected] \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  plugins/npm:latest

Output:

latest: Pulling from plugins/npm
Digest: sha256:5bf18853264a6ff85c87d1472fdc8ec181c5dd10161cfa744042259dbcfac5a7
Status: Image is up to date for plugins/npm:latest
docker.io/plugins/npm:latest

time="2022-12-15T21:56:27Z" level=info msg="Specified credentials" [email protected] username=drone
time="2022-12-15T21:56:27Z" level=info msg="Found package.json" name=foobar path=package.json version=1.0.0
time="2022-12-15T21:56:27Z" level=info msg="Specified credentials" [email protected] username=drone
time="2022-12-15T21:56:27Z" level=info msg="Writing npmrc" path=/root/.npmrc
+ npm --version
9.1.2
+ npm config set always-auth true
npm ERR! `always-auth` is not a valid npm option

Suggested Fix

Given that always-auth was seemingly removed in NPM 7.11.1, perhaps we can simply stop setting it in plugins/npm at this point.

Workaround

To work around this, you can request a previous version of plugins/npm by digest:

docker pull plugins/npm@sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a

docker run --rm \
  -e NPM_USERNAME=drone \
  -e NPM_PASSWORD=password \
  -e [email protected] \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  plugins/npm@sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a

Output:

docker.io/plugins/npm@sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a: Pulling from plugins/npm

Digest: sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a
Status: Image is up to date for plugins/npm@sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a
docker.io/plugins/npm@sha256:4f0ad309dd7438248ff3323439cc79f259b6bf7064d847766d769e0b440aec7a

time="2022-12-15T22:10:32Z" level=info msg="Specified credentials" [email protected] username=drone
time="2022-12-15T22:10:32Z" level=info msg="Found package.json" name=foobar path=package.json version=1.0.0
time="2022-12-15T22:10:32Z" level=info msg="Specified credentials" [email protected] username=drone
time="2022-12-15T22:10:32Z" level=info msg="Writing npmrc" path=/root/.npmrc
+ npm --version
8.1.3
+ npm config set always-auth true
+ npm whoami
drone
+ npm view foobar versions --json
time="2022-12-15T22:10:34Z" level=info msg="Version found in the registry"
time="2022-12-15T22:10:34Z" level=info msg="Not publishing package"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions