node.jsnpmteamcity-9.0sinopia

"npm publish" not working in Team City


I am trying to use Team City CI to run tests and publish the NPM package to local sinopia repository. I had setup sinopia repository on a server and i can successfully publish npm packages to that repository with npm publish command from my local machine.

But when i try to automate this in Team City , i am getting authentication error as shown below.

enter image description here

Team City Build steps are :

1.  npm install
2.  npm test
3.  npm set @scoped:registry http://{host}:{port}
    npm publish

1, 2 steps are running fine. But throwing above error on 3rd step. It definitely has to do with authenticating the Team City server with Sinopia server. Both are installed in different machines.

Is there any way i can pass auth token to sinopia before publishing a package.

NOTE : I can publish NPM packages to Octopus Deploy library and deploy those packages into server automatically.


Solution

  • I solved it as explained below, not sure if there is any better way.

    I logged into my DEV Server and from the command prompt i ran the below commands.

    npm adduser
    typed <username>  This must be admin user
    typed <password>
    typed <email>
    

    User created succesfully. Then

    npm config edit
    npm configuration will open in notepad. You will see `auth` token there.
    

    You will see something like _authToken=f04c81af-781d-4fc3-a811-4db226950b55. Then onwards Team city didn't complain about authentication.

    NOTE : You have to do this on Team City Agent machine.

    Hope this helps.