Home > Net >  Error when trying to publish node project to Nexus[Jenkins-Nodejs]
Error when trying to publish node project to Nexus[Jenkins-Nodejs]

Time:11-17

with Jenkins I get an error when trying to publish node project(React app) to Nexus.

Pipeline Script:

node ("test-label") {
    stage('checkout'){
            sh 'git clone -b react-1 https://gitlab.com/.../ui/test.git .'
    }
    stage ('Build'){
        container('node'){
            script {
                sh "set  x && echo \"//mynexusurl/repository/npm-private/:_authToken=NpmToken.******\" >> .npmrc"
                sh 'npm publish'
          }
        }
    }
}

Error:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`

If I add the following code to the package.json file in the project, it works fine, but I don't want to enter this information in the package.json file.

"publishConfig": {
    "registry": "http://mynexus/repository/npm-private/"
}

How can I fix package.json without giving publishConfig information?

CodePudding user response:

I fixed the problem as follows

sh "npm publish --registry http://nexusurl/repository/npm-private/"
  • Related