'npm premature close on jenkins build
I'm setting up a Jenkins build for our internal NodeJS Express project.
The project uses some native libraries (written in C). After trial & error setting up Python, MSBuild Tools (with windows-build-tools and without), I didn't managed to get the build working.
Jenkins script:
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"
}
}
}
}
I've tried with the NodeJS plugin, same issue. Granted permissions to the C:\Program Files (x86)\Jenkins folder and every sub-directory, reinstalled everything (packages, Node with different versions, even my Windows OS), but the output is always:
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
The weird thing is that when I run npm install from the %JENKINS_HOME%workspace/ProjectName folder, it builds and installs everything without any warnings or errors and runs smoothly.
Sorry for the long text, I've done a 3 week research on this topic, saw many articles and posts, but this problem has been for a longer period and we can't manage to build any of our Node projects.
Solution 1:[1]
The simplest way to solve this issue is just
yarn install instead of npm install
And then:yarn add --save github:user/repo
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gyan_JS _2008 |
