前端开发用的是高版本的nodejs,测试服务器jenkins打包用的是低版本的nodejs,升级(覆盖重装)服务器上的nodejs保持环境一致,结果jenkins打包就一致失败,js文件会有缺失的问题,在shell下编译报错。。。
......
gyp verb remove removing target version: 10.15.3
gyp verb remove removing development files for version: 10.15.3
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/jenkins/.jenkins/workspace/h5-front-rebuild/node_modules/node-sass/.node-gyp'
gyp ERR! System Linux 2.6.32-642.el6.x86_64
gyp ERR! command "/usr/local/node-v10.15.3/bin/node" "/home/jenkins/.jenkins/workspace/h5-front-rebuild/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/jenkins/.jenkins/workspace/h5-front-rebuild/node_modules/node-sass
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@6.0.7 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN yi@1.3.0 No repository field.
npm WARN yi@1.3.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.11.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-04-26T01_59_36_792Z-debug.log
分析报错信息:得出需要配置npm解决,重新安装node-sass即可。
npm config set user 0
npm config set unsafe-perm true
npm rebuild node-sass
或者
sudo npm install node-sass --unsafe-perm --save-dev
安装完重新启动就ok了, 所以没事还是别更新node,最好保持团队的环境一致。