简体   繁体   中英

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

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?

I fixed the problem as follows

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM