尝试将我的代码从Circleci部署到Firebase时出错

时间:2019-07-15 16:55:36

标签: node.js firebase npm circleci

这是我第一次使用CircleCI,因此我遵循了本教程hier。我正在使用它来构建,测试并将我的角度应用程序部署到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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

我也有同样的问题。

我设置circleci / node:10.16-浏览器