Jenkins管道中的“找不到模块”

时间:2019-05-07 01:40:31

标签: node.js jenkins npm

我的管道本质上:

  1. 使用mysql运行docker并在此数据库上进行迁移迁移
  2. 进行单元测试
  3. 在AWS数据库上本地运行迁移迁移
  4. 部署到AWS lambda

由于第3步失败并出现以下错误,因此无法到达第4步:

added 806 packages in 12.979s
module.js:549
    throw err;
    ^

Error: Cannot find module 'es5-ext/object/assign'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/lib/jenkins/workspace/Develop/backend/products/node_modules/d/index.js:3:21)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/lib/jenkins/workspace/Develop/backend/products/node_modules/cli-color/index.js:3:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/lib/jenkins/workspace/Develop/backend/products/node_modules/sequelize-cli/lib/helpers/view-helper.js:3:17)
    at Module._compile (module.js:652:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! product-api@1.0.0 migrate: `npm i; ./node_modules/.bin/sequelize db:migrate`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the product-api@1.0.0 migrate 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!     /var/lib/jenkins/.npm/_logs/2019-05-07T01_24_39_404Z-debug.log

这是管道:

stage('Bring up MySQL Docker and Migrations') {
      steps {
          sh 'pwd'
          sh 'sudo npm run playpen-stop'
          sh 'sudo npm run playpen-start'
      }
    }

    stage('Unit testing') {

      steps {
        dir ('backend/products') {
           sh 'npm run test'
        }
      }
    }
    stage('Running sequelize migrations') {
      steps {

          dir ('backend/products') {
            // FAILS HERE
            sh 'npm run migrate'
          }
      }
    }
}

npm运行迁移脚本是:

"npm i; ./node_modules/.bin/sequelize db:migrate",

我尝试过的事情:

  1. 清理缓存
  2. 使用sudo进行迁移
  3. 使用NVM在jenkins终端上重新安装节点

0 个答案:

没有答案