簡體   English   中英

npm 在 jenkins 版本上過早關閉

[英]npm premature close on jenkins build

我正在為我們的內部 NodeJS Express 項目設置一個 Jenkins 構建。

該項目使用一些本機庫(用 C 編寫)。 在試錯設置 Python、MSBuild 工具(帶或不帶windows-build-tools )之后,我沒能成功構建。

Jenkins 腳本:

pipeline {
  agent any

  stages {
    stage('Download source') {
        steps {
            checkout([
                $class: 'GitSCM', 
                branches: [[name: '*/branch-name']], 
                userRemoteConfigs: 
                [
                    [
                        credentialsId: 'cred-id', 
                        url: 'gitURL'
                    ]
                ]
            ])
        }
    }

    stage('Npm install') {
      steps {
        bat "npm install"
      }
    }
  }     
}

我試過 NodeJS 插件,同樣的問題。 授予對C:\Program Files (x86)\Jenkins文件夾和每個子目錄的權限,重新安裝所有內容(包、不同版本的節點,甚至我的 Windows 操作系統),但 output 始終是:

step: npm install
npm ERR! premature close

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2019-04-04T16_69_111Z-debug.log

奇怪的是,當我從%JENKINS_HOME%workspace/ProjectName文件夾運行npm install時,它會在沒有任何警告或錯誤的情況下構建和安裝所有內容,並且運行順利。

抱歉,文字太長了,我已經對這個主題進行了 3 周的研究,看到了很多文章和帖子,但這個問題已經存在了更長的時間,我們無法設法構建我們的任何 Node 項目。

好的,經過2個星期的痛苦嘗試后,唯一可行的解​​決方案是:

yarn install

代替:

npm install

解決這個問題的最簡單方法就是

yarn install而不是npm install

然后:
yarn add --save github:user/repo

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM