I am in the middle of trying to implement a build/deploy job in Jenkins by which the latest version of source code is pulled from git, built and then deployed to GCP. So far i am able to retrieve the lastest code from GIT but have run into issues when tyring to build. The application being built/deployed is an Angular 7 web site using npm for package management. So the normal steps would be to run npm install to make sure the packages are installed and then ng build -- prod to build the app. My issue is that the version of npm/nodejs in the master node is out of date and not compatable with Angular 7. Even just trying the command to gert the current ng version fails:
+ /usr/bin/ng v You are running version v8.1.4 of Node.js, which is not supported by Angular CLI v6. The official Node.js version that is supported is 8.9 and greater.
I added a call to npm version to check the npm version is is trying to use:
+ echo current user current user + whoami jenkins + npm -v 5.0.3
To investigate the issue i used putty to remote onto the jenkins box and ran npm -v and ng v to see what is installed and get:
jenkins@****-int1:~$ npm -v 6.5.0-next.0
Which is different to that reported by npm -v in the shell script.
jenkins@****:~$ ng v _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/ Angular CLI: 7.1.4 Node: 11.6.0 OS: linux x64 Angular: ... Package Version ------------------------------------------------------ @angular-devkit/architect 0.11.4 @angular-devkit/core 7.1.4 @angular-devkit/schematics 7.1.4 @schematics/angular 7.1.4 @schematics/update 0.11.4 rxjs 6.3.3 typescript 3.1.6
So it should have nodejs 11.6, i ran node -v to double check:
jenkins@****:~$ node -v v11.6.0
BUT if i run nodejs -v i get:
jenkins@****:~$ nodejs -v v8.1.4
I thought that node and nodejs were the same thing? so why would i have two different versions installed and how to i fix this?
To double check what my Jenkins script is using i added a call to node -v in the script and as expected it reports the older version:
+ node -v v8.1.4
I should add that i'm not a devops person, i'm C# back end developer who's been lumbered with sorting this out due staff changes. I know very little about linux, Jenkins or this stuff in general :(
I tried to update the node installation via the Jenkins Shell script using
sudo npm cache clean -f sudo npm install -g n sudo n stable
But these were refused due to access rights (no sudo pwd i presume) and i don't know if that would've fixed the issue anyway.
Any help would be much appreciated....