node 版本过低

构建项目时报错

Error: Cannot find module 'chalk'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/apps2/jenkins/jobs/bpg_yunying_ucenter_fe/workspace/build/check-versions.js:1:75)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
Build step 'Execute shell' marked build as failure

解决办法

  • 在构建脚本中添加如下代码

    source /etc/profile;
    nvm use v8.11.2
    原文作者:Snoopy
    原文地址: https://segmentfault.com/a/1190000018391633
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞