【问题标题】:npm premature close on jenkins buildnpm 过早关闭 jenkins 构建
【发布时间】:2019-08-26 12:36:17
【问题描述】:

我正在为我们的内部 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 操作系统),但输出始终是:

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 项目。

【问题讨论】:

    标签: node.js jenkins npm deployment node-gyp


    【解决方案1】:

    好的,经过 2 周的痛苦尝试后,唯一可行的解​​决方案是:

    yarn install

    代替:

    npm install

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 2013-05-27
      • 1970-01-01
      • 2015-06-25
      相关资源
      最近更新 更多