Skip to content

Last alpine image breaks npm install with git+ssh #1378

Closed

Description

@damiankoper

It looks like NPMv7 npm install wants to use bash, which is not present in alpine image. NPMv6 works fine on lts-alpine.
DIGEST: sha256:97204ef250fa90f8177084ef6d7641ede6d48c4c8acfb30faf3580bee5c59c0b

Is it NPM problem or with some settings connected with latest image?

Log:

npm WARN tarball tarball data for XXX@git+ssh://git@github.com/XXX/XXX.git#hash (null) seems to be corrupted. Trying again.
npm WARN tarball tarball data for XXX@git+ssh://git@github.com/XXX/XXX.git#hash (null) seems to be corrupted. Trying again.
npm notice 
npm notice New patch version of npm available! 7.0.2 -> 7.0.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.3>
npm notice Run `npm install -g npm@7.0.3` to update!
npm notice 
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path bash
npm ERR! errno -2
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

Activity

  1. SimenB commented on Oct 23, 2020

    @SimenB
    Member

    I don't know what package you're trying to install - I'm assuming it is due to some pre-built binary not being available, so it attempts to build from source, which requires bash. Hard to tell without more details, however.

    I don't think it's a bug in this image or in npm. I might be wrong though. You should take a look at the logfile after the failure.

  2. damiankoper commented on Oct 23, 2020

    @damiankoper
    Author

    It looks like NPMv7 issue:
    npm/cli#2008
    npm/cli#2022
    So this issue can be closed.

  3. damiankoper commented on Oct 25, 2020

    @damiankoper
    Author

    It turns out that NPMv7 respects shell config option and NPMv6 does not (in this case).

    NPMv6:

    damian_koper@X:~/Desktop/npm-test $ docker run -it node:lts-alpine sh
    / # npm -v
    6.14.8
    / # npm config ls -l | grep shell
    script-shell = null
    shell = "bash"
    / # apk add git
    OK: 23 MiB in 22 packages
    / # npm i github:damiankoper/piw.git # random repo
    # WORKS

    NPMv7:

    damian_koper@X:~/Desktop/npm-test $ docker run -it node:alpine sh
    / # npm -v
    7.0.3
    / # npm config ls -l | grep shell
    script-shell = null 
    shell = "bash" 
    / # apk add git
    OK: 23 MiB in 22 packages
    / # npm i github:damiankoper/piw.git # random repo
    npm ERR! code ENOENT
    npm ERR! syscall spawn bash
    npm ERR! path bash
    npm ERR! errno -2
    npm ERR! enoent spawn bash ENOENT
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent

    Solution for NPMv7:

    /app # npm config set shell sh # Should this be added to alpine Dockerfile with NPMv7?
    validBefore? true
    / # npm i github:damiankoper/piw.git # random repo
    WORKS
  4. SimenB commented on Oct 25, 2020

    @SimenB
    Member

    so npm defaults to bash? They should probably default to. sh as that's more portable. We can probably set that config option, tho.

  5. Tchoupinax commented on Nov 9, 2020

    @Tchoupinax

    I had the same issue (installing package from git) and adding the following line in my Dockerfile fixes the issue. Thanks @damiankoper

    npm config set shell sh
    

    Edit: answer to the next comment, yes v15.1.0 solve the issue ^^

  6. nschonni commented on Nov 9, 2020

    @nschonni
    Member

    Default shell was fixed in NPM and included in the 15.1.0 images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions