本文共 1455 字,大约阅读时间需要 4 分钟。
NodeJs的镜像网址:
一、安装nodejs
下载nodes,并安装:
# cd /app/service_tools/# wget https://npm.taobao.org/mirrors/node/v9.3.0/node-v9.3.0-linux-x64.tar.xz# xz -d node-v9.3.0-linux-x64.tar.xz# tar xf node-v9.3.0-linux-x64.tar# ln -s /app/service_tools/node-v9.3.0-linux-x64 /app/service_tools/node-v9.3.0# ln -s /app/service_tools/node-v9.3.0/bin/node /usr/bin/node# ln -s /app/service_tools/node-v9.3.0/bin/npm /usr/bin/npm如果可以查看到版本号证明安装成功:[root@iZ256df41lxZ ~]# node -vv9.3.0[root@iZ256df41lxZ ~]# npm -v5.5.1
有时候通过npm编译前端项目的时候出现报错:
npm ERR! path /app/Jenkins/.jenkins/workspace/test-marketweb-second/package.jsonnpm ERR! code ENOENTnpm ERR! errno -2npm ERR! syscall opennpm ERR! enoent ENOENT: no such file or directory, open '/app/Jenkins/.jenkins/workspace/test-marketweb-second/package.json'npm ERR! enoent This is related to npm not being able to find a file.npm ERR! enoent npm ERR! A complete log of this run can be found in:npm ERR! /root/.npm/_logs/2018-06-12T09_51_48_611Z-debug.logBuild step 'Execute shell' marked build as failureSSH: Current build result is [FAILURE], not going to run.Finished: FAILURE
遇到这种问题可以尝试安装cnpm命令和webpack:
# npm install -g cnpm --registry=https://registry.npm.taobao.org# ln -s /app/service_tools/node-v9.3.0/bin/cnpm /usr/bin/cnpm# cnpm install webpack -g
Jenkins 配置:
在“系统管理”—>”Global Tool Configuration"中设置nodejs的安装方式,或者安装路径:一、新建项目选择“构建一个自由风格的软件项目”
二、项目配置
在构建环境中设置环境为node环境构建命令:
转载于:https://blog.51cto.com/11019859/2128812