首页 > 解决方案 > 如何忽略 npm 运行错误并继续使用 Travis-CI?

问题描述

我在 Travis 配置中有阶段启动npm run build,其中构建是转换 ts -> js 的脚本。在本地,它返回两个无关紧要的错误,无论如何我都可以运行服务器。但是,这些错误阻止了 Travis 继续前进并失败了。

    - stage: "Build front"
      before_script:
        - cd front
        - npm install
        - npm run build

错误:

...
[0] npm run build:client exited with code 0
build/setupProdServer.ts(6,20): error TS2307: Cannot find module '../src/vue-ssr-server-bundle.json'.
build/setupProdServer.ts(7,28): error TS2307: Cannot find module '../src/vue-ssr-client-manifest.json'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
...

我尝试添加

allow-failures:
        - node
        - npm

它没有帮助。

我需要 Travis 忽略这些错误并进入下一阶段。

Travis 中什么样的命令或参数会解决它?

标签: npmconfigtravis-ci

解决方案


只需添加|| true

- npm run build || true


推荐阅读