简体   繁体   中英

npm: not found when setting up Jenkins Server?

This is my first time setting up a jenkins server. The build is using Amazon's EC2 and Ubuntu 14.04.

I've installed node and npm via nvm .

node -v
>v0.11.14

npm -v
>2.0.0

The repo pulls down just fine into my /var/lib/jenkins/workspace/morningharwood folder.

Problem: When I add my script it breaks

Here's my build script which errors out? I have no idea what i'm doing. I copied this from a tutorial.

在此处输入图片说明

QUESTION: How do I properly write my script to npm install , bower install and lastly, grunt test

You could install node, npm, bower and grunt by doing following:

sudo apt-get install node
sudo npm install bower
sudo npm install grunt

To install a package from local source, use

npm install /path

尝试使用 Jenkins 的 NodeJS 插件: https : //wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

This will solve npm command not found issue on jenkins even installed on server

sudo mkdir /usr/local/nvm
export NVM_DIR=/usr/local/nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh |NVM_DIR=/usr/local/nvm bash

. /usr/local/nvm/nvm.sh
nvm install 10.15.3 -g
npm install @angular/cli -g

Include following on build execute shell command in jenkins:

export PATH="$PATH:/usr/local/nvm/versions/node/v10.15.3/bin"
npm install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM