Unexpected token 'var'
See original GitHub issueI am trying to comment on a PR via a workflow and keep getting this exception:
SyntaxError: Unexpected token 'var'
at new AsyncFunction (<anonymous>)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4942:56)
at main (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4997:26)
at Module.272 (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4981:1)
Error: Unhandled error: SyntaxError: Unexpected token 'var'
at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:24:31)
at startup (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:43:19)
at /home/runner/work/_actions/actions/github-script/v5/dist/index.js:49:18
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:52:10)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
The code is really simple
- name: Comment on PR
uses: actions/github-script@v5
if: failure()
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "foo"
})
Github support asked me to log a bug report here as well.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Uncaught SyntaxError: Unexpected token var - Stack Overflow
I have an error Uncaught SyntaxError: Unexpected token var displayed between (1) and (2) its a very odd error and it doesn't make...
Read more >What does "Syntax error: Unexpected token var" mean?
Given the error you received it seems most likely that you tried to declare a variable incorrectly. My guess is that you might...
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 >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >uncaught syntaxerror - unexpected token 'var' - Syncfusion
uncaught syntaxerror - unexpected token 'var' · Hi · Due to the critical need of reported bug 'Component not rendering properly in multi...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you need to pass into multi-line outputs into the
script
block, you’ll likely need to pass those values in as environment variables. Otherwise, newlines will be interpreted literally in the script and won’t be valid JavaScript.Example:
So I encountered this same issue and was able to resolve it using below as per @joshmgross’s recommendation