【问题标题】:Error while trying to deploy my code from circleci to firebase尝试将我的代码从 circleci 部署到 firebase 时出错
【发布时间】:2019-08-06 22:14:30
【问题描述】:

这是我第一次使用 CircleCI,所以我跟着这个教程hier。我正在使用它来构建、测试我的 Angular 应用并将其部署到 Firebase。

我尝试寻找但找不到任何东西。我尝试更改节点版本,但没有帮助。我还在我的机器上运行了相同的命令进行部署,它在那里工作,我查看 dist 文件夹是否为空,但不是。

circleCI config.yml 的部署部分:

deploy:
        docker:
            - image: circleci/node:chakracore-8.11-browsers-legacy
        working_directory: ~/project
        steps:
            - run:
                name: Show current branch
                command: echo ${CIRCLE_BRANCH}
            - restore_cache:
                key: v1-dist-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
            - run:
                name: Install Firebase
                command: npm install --save-dev firebase-tools
            - run:
                name: Deploy Master to Firebase
                command: npm run firebase-deploy --token=$FIREBASE_TOKEN

package.json 的脚本:

 "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-prod": "ng build --prod=true",
    "test": "ng test",
    "test-prod":  "ng test --watch=false",
    "firebase-deploy": "firebase deploy",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },

尝试部署时的错误信息:

#!/bin/bash -eo pipefail
npm run firebase-deploy --token=$FIREBASE_TOKEN

> first-page@0.0.0 firebase-deploy /home/circleci/project
> firebase deploy

/home/circleci/project/node_modules/open/index.js:29
        ...options
        ^^^^

SyntaxError: Expected identifier, string or number
   at createScript (vm.js:80:3)
   at runInThisContext (vm.js:139:3)
   at Module.prototype._compile (module.js:616:3)
   at Module._extensions[.js] (module.js:663:3)
   at Module.prototype.load (module.js:565:3)
   at tryModuleLoad (module.js:505:5)
   at Module._load (module.js:497:3)
   at Module.prototype.require (module.js:596:3)
   at require (internal/module.js:11:7)
   at Anonymous function (/home/circleci/project/node_modules/firebase-tools/lib/commands/functions-log.js:12:1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! first-page@0.0.0 firebase-deploy: `firebase deploy`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the first-page@0.0.0 firebase-deploy 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!     /home/circleci/.npm/_logs/2019-07-15T16_50_44_850Z-debug.log
Exited with code 1

【问题讨论】:

    标签: node.js firebase npm circleci


    【解决方案1】:

    我也遇到了同样的问题。

    我设置了 circleci/node:10.16-browsers

    【讨论】:

      【解决方案2】:

      您是否将$FIREBASE_TOKEN 设置为环境变量。如果没有,请设置它。您也可以通过直接传递给命令来测试它。喜欢npm run firebase-deploy --token={your token string}

      【讨论】:

      • 是的,我做到了,令牌很好
      • 你的意思是直接传递令牌,它工作正常?
      • 不行,直接传入token还是不行。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 2018-07-12
      • 2019-07-14
      • 2020-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多