Issue
I have an Angular app that I'm trying to deploy through Jenkins. The standard DEV build works fine, but when I do a ng build --prod
it says "ng: command not found".
When running a command with npm run ng build -- --prod
, it says "line 1: 6910 Killed " followed by the failed command
Last week, I could get a prod build to finish successfully, but not pick up the environment.prod.ts file. Today, I get one of the two above errors.
I've tried the following build commands:
sh "ng build --prod"
sh "npm run ng build -- --configuration=production"
sh "npm run ng build -- --configuration production"
sh "npm run ng build -- --configuration=production --target=production --environment=prod"
sh "npm run ng build --configuration=production --target=production --environment=prod"
sh "npm run ng build -- --prod"
sh "npm run ng build -- --configuration prod"
sh "npm run ng build -- --configuration production"
sh "npm run ng build myCoolProjectName --prod --configuration=production"
sh "npm run ng build myCoolProjectName --prod --configuration production"
sh "npm run ng build --prod --configuration=production"
sh "npm run ng build --prod --configuration production"
sh "npm run ng build --configuration=production"
I'm running the following versions on my Jenkins server's AWS EC2 instance: Angular CLI: 12.0.3, Node: 16.2.0, Package Manager: npm 7.13.0, OS: linux x64
Here's the important parts of my Jenkinsfile:
tools {
//nodejs 'NodeJS 12.18.1'
nodejs 'NodeJS 16.2.0'
}
stage('npm install') {
steps {
sh 'npm install'
}
}
stage('Build') {
steps {
script{
if("${ENVIRO}" == "prod") {
PROFILE = "my-prod"
sh "npm run ng build -- --prod"
} else if("${ENVIRO}" == "qa"){
PROFILE = "my-qa"
sh "npm run ng build -- --configuration production"
}
else {
PROFILE = "my-dev"
sh "npm run ng build"
}
}
}
}
Edit: I added a screenshot of the memory usage. The swiggle on the end of the red line is when I did a build(it failed). It seems to have plenty available.
Any help would be greatly appreciated and I'd be happy to supply more info.
Cheers,
Andy
Solution
Line 1 killed most likely happens because the machine in the clouds (on Jenkins) is running out of memory.
Try adding memory to the machine or killing processes that are taking memory so the Angular build has more memory to operate on.
You can also try running this:
// make node.js process take 1.5GB of space
node --max_old_space_size=1500 ./node_modules/.bin/ng build -- --prod
See this for more info.
Answered By - AliF50