question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected token '}' error

See original GitHub issue

Hi, thanks for the very useful GHA tool here. The following error is seen here:

SyntaxError: Unexpected token '}'
    at new AsyncFunction (<anonymous>)
    at main (/home/runner/work/_actions/actions/github-script/0.3.0/main.js:19:14)
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/0.3.0/main.js:5:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11
##[error]Unexpected token '}'
##[error]Node run failed with exit code 1

but it’s not clear what’s going wrong, since it looks correctly written (and has worked in other repositories just fine). We have a step that looks like so:

    - name: Comment that something failed
      if: failure()
      uses: actions/github-script@0.3.0
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        script: |
          github.issues.createComment({...context.issue, body: ":cry: Something went wrong. I am not able to push. Check the [Actions pipeline](https://github.com/${{ github.repository }}/actions?query=workflow%3A%22Tag+Creator%22) to see what happened. If you make any more changes, you probably want to re-trigger me again by adding the `bumpversion/${{ env['BV_PART'] }}` label again."})
          github.issues.removeLabels({...context.issue, "bumpversion/${{ env['BV_PART'] }}" })

with the following env:

  env:
    IS_MAJOR: false
    IS_MINOR: false
    IS_PATCH: true
    PR_NUMBER: 38
    PR_TITLE: Revert "Revert "ci: Add release via bumpversion tag GHA workflow""
    GITHUB_HEAD_REF: revert-36-revert-35-ci-add-publishing-throuhg-bumpversion-label
    BV_PART: patch

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jclemcommented, Feb 20, 2020

@kratsg The key is name—that’s the key being used in the documentation and in my example (though you may have seen it before I updated it to match the documentation).

In this JavaScript object:

{
  owner,
  repo,
  issue_number,
  name
}

The keys are owner, repo, issue_number, and name whose values are variables of the same names. The documentation is using ES6 property/value shorthand.

0reactions
buttspcommented, Mar 5, 2021

Hi All,

I am getting a similar error when I do: … - name: Terraform Init run: terraform -chdir=./src/infra init …

`Run terraform -chdir=./src/infra init /home/github-runner-elsa/actions-runner/_work/_temp/xxxxx-ab34-afa9f59e47e1/terraform:75 function cp(source, dest, options = {}) { ^

SyntaxError: Unexpected token = at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions…js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:442:10) at startup (node.js:136:18) at node.js:966:3 Error: Process completed with exit code 1.`

My workflow Infrastructure.yaml is :

`name: Infrastructure

on: workflow_dispatch: push: branches: - ‘main’ paths: - ‘src/infra/’ pull_request: branches: - ‘main’ paths: - 'src/infra/

env: ARM_CLIENT_ID: ${{secrets.INFRA_TF_CLIENT_ID}} ARM_CLIENT_SECRET: ${{secrets.INFRA_TF_CLIENT_SECRET}} ARM_SUBSCRIPTION_ID: ${{secrets.INFRA_TF_SUBSCRIPTION_ID}} ARM_TENANT_ID: ${{secrets.INFRA_TF_TENANT_ID}} TF_VAR_location: westeurope

jobs: terraform_dev: runs-on: self-hosted #environment: dev

env:
  TF_VAR_resource_name: gidif-devops-dev
  TF_VAR_sql_user: ${{secrets.INFRA_TF_SQL_USER}}
  TF_VAR_sql_password: ${{secrets.INFRA_TF_SQL_PASSWORD}}

steps:
  - uses: actions/checkout@v2

  - name: Setup Terraform
    uses: hashicorp/setup-terraform@v1

  - name: Terraform Init
    run: terraform -chdir=./src/infra init

  - name: Terraform Format
    run: terraform -chdir=./src/infra fmt -check

  - name: Terraform Workspace DEV
    run: terraform -chdir=./src/infra workspace new dev
    continue-on-error: true

  - name: Terraform Select Workspace DEV
    run: terraform -chdir=./src/infra workspace select dev

  - name: Terraform Plan
    run: terraform -chdir=./src/infra plan


  - name: Terraform Apply
    if: github.ref == 'refs/heads/main'
    run: terraform -chdir=./src/infra apply -auto-approve

terraform_prd: runs-on: self-hosted #environment: prd if: github.ref == ‘refs/heads/main’ needs: terraform_dev

env:
  TF_VAR_resource_name: gidif-devops-prd
  TF_VAR_sql_user: ${{secrets.INFRA_TF_SQL_USER}}
  TF_VAR_sql_password: ${{secrets.INFRA_TF_SQL_PASSWORD}}

steps:
  - uses: actions/checkout@v2

  - name: Setup Terraform
    uses: hashicorp/setup-terraform@v1

  - name: Terraform Init
    run: terraform -chdir=./src/infra init

  - name: Terraform Format
    run: terraform -chdir=./src/infra fmt -check

  - name: Terraform Create Workspace PRD
    run: terraform -chdir=./src/infra workspace new prd
    continue-on-error: true

  - name: Terraform Select Workspace PRD
    run: terraform -chdir=./src/infra workspace select prd

  - name: Terraform Plan
    run: terraform -chdir=./src/infra plan

  - name: Terraform Apply
    if: github.ref == 'refs/heads/main'
    run: terraform -chdir=./src/infra apply -auto-approve`

I have a self hosted linux runner and I am using Github Enterprise server.

On my runner VM, i have also did the following, but no luck:

apt update apt install nodejs ln -s /usr/bin/nodejs /usr/local/bin/node

It seems the node version installed on the runner is newer than the one expected to build the pipe? if true, which node version do i need on my runner? terraform init requires node?

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Have a JavaScript Unexpected Token Error? Check Your Syntax
The JavaScript's parser expects tokens and symbols in a particular order, with relevant values or variables in between. Often, an Unexpected ...
Read more >
JavaScript Error Handling: Unexpected Token - GeeksforGeeks
Not follow them throws an error.An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + –...
Read more >
How to fix: "SyntaxError: Unexpected token" in JavaScript
One common cause of the SyntaxError: Unexpected token error is a missing semicolon. In JavaScript, semicolons are used to indicate the end of...
Read more >
syntax error: unexpected token - javascript - Stack Overflow
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >
SyntaxError: Unexpected token in JavaScript - Stack Diary
The "SyntaxError: Unexpected token" error in JavaScript is a common syntax error that occurs when the JavaScript interpreter encounters a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found