npm adduser via bash

前端 未结 9 1392
清歌不尽
清歌不尽 2021-02-01 18:48

I want to automate the npm login process via a bash script.

I tried it with this snippet:

/usr/bin/expect -f - <

        
相关标签:
9条回答
  • 2021-02-01 19:21

    I don't know if it is in any way secured so please do some research before.

    But the fact is that npm is storing all those informations into a file. If you look at:

    cat ~/.npmrc
    

    It could be interesting enough so you could do the login dance only once.

    0 讨论(0)
  • 2021-02-01 19:22

    I found that on Windows Server 2012R2, there is some odd behaviour with service accounts. This method worked for me (as part of a Jenkins build, under bash):

    cat > ~/.npmrc <<EOL
    //my.local.registry:4873/:_authToken="G....................A=="
    always_auth=true
    registry=http://my.local.registry:4873/
    user=aRegisteredUser
    EOL
    
    0 讨论(0)
  • 2021-02-01 19:22

    My Solution is to use plugin npm-login-cmd

    npm install -g npm-login-cmd
    
    export NPM_USER=user
    export NPM_PASS=pass
    export NPM_EMAIL=valid email syntax
    npx npm-login-cmd
    

    login work on enterprice npm repository

    0 讨论(0)
提交回复
热议问题