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.

UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token in JSON at position 3324

See original GitHub issue

Prerequisites

  • I am running the latest version of Node and the tools
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected behavior

The generator demo should work

Current behavior

 yo office

     _-----_     ╭──────────────────────────╮
    |       |    │   Welcome to the Office  │
    |--(o)--|    │   Add-in generator, by   │
   `---------´   │ @OfficeDev! Let's create │
    ( _´U`_ )    │    a project together!   │
    /___A___\   /╰──────────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

? Choose a project type: Office Add-in Task Pane project supporting single sign-on
? Choose a script type: JavaScript
? What do you want to name your add-in? SSO365
? Which Office client application would you like to support? Word

----------------------------------------------------------------------------------

      Creating SSO365 add-in for Word using JavaScript and Single-sign-on at C:\SSO365

----------------------------------------------------------------------------------

      Congratulations! Your add-in has been created! Your next steps:

      1. Go the directory where your project was created:

         cd C:\SSO365

      2. Configure your SSO taskpane add-in:

         npm run configure-sso

      3. Start the local web server and sideload the add-in:

         npm start

      4. Open the project in VS Code:

         code .

         For more information, visit http://code.visualstudio.com.

      Please visit https://docs.microsoft.com/office/dev/add-ins for more information about Office Add-ins.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. run generator as above
  2. run npm run configure-sso

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System: Windows 10 Pro 10.0.19042 Build 19042
  • Node version: 14.15.4
  • Office version: 2101 Build 13628.20380 Click-to-Run (Microsoft 365 Apps for business )
  • Tool version: yeoman latest

Failure Logs

npm run configure-sso

> office-addin-taskpane-sso-js@0.0.0 configure-sso C:\SSO365
> office-addin-sso configure manifest.xml

(node:17100) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token  in JSON at position 3324
    at JSON.parse (<anonymous>)
    at C:\SSO365\node_modules\office-addin-sso\lib\configure.js:188:40
    at Generator.next (<anonymous>)
    at C:\SSO365\node_modules\office-addin-sso\lib\configure.js:6:71
    at new Promise (<anonymous>)
    at __awaiter (C:\SSO365\node_modules\office-addin-sso\lib\configure.js:2:12)
    at C:\SSO365\node_modules\office-addin-sso\lib\configure.js:182:95
    at ChildProcess.exithandler (child_process.js:299:7)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:17100) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17100) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:33 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
TCourtneyOwencommented, Feb 16, 2021

Btw, I just published a new version of the SSO template, so if you create a new SSO project via Yo Office, it will have the “office-addin-sso” package update.

Can you please try the running the following at the root of your project to work around the loopback issue:

  • Run “npx office-addin-dev-settings appcontainer manifest.xml --loopback”
  • Say Yes when prompted with Allow localhost loopback for manifest.xml?
1reaction
akrantzcommented, Feb 13, 2021

The starting templates are in separate github repositories. You can clone them and start with them.

However, be sure to customize the manifest and use a unique id by running: npx office-addin-manifest modify --guid --displayName <name>

Here are a few of them: Basic: https://github.com/OfficeDev/Office-Addin-TaskPane React: https://github.com/OfficeDev/Office-Addin-TaskPane-React SSO: https://github.com/OfficeDev/Office-Addin-TaskPane-SSO

The yo-office branch is what is used when you run yo office. The master branch may have more recent changes which should work. We’re constantly working to keep these templates updated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token < in JSON at position 0
Since it looks like the error seems to have something to do with pulling JSON data from the server, I tried starting from...
Read more >
What Is JSON and How to Handle an “Unexpected Token” Error
The first thing to do in this situation is to confirm where the error is happening exactly. To ensure the error happens on...
Read more >
How to Fix SyntaxError: Unexpected token < in JSON at ...
Usually this error is caused when your server returns HTML (which typically begins with <DOCTYPE html> or <html> ) instead of JSON. Valid...
Read more >
Unexpected token in JSON at position 0 - Moodle.org
Re: Unexpected token in JSON at position 0 ... This usually means that an error has been returned and that's not valid JSON....
Read more >
SyntaxError: Unexpected token < in JSON at position 3
SyntaxError : Unexpected token < in JSON at position 3 ... what can be caused this error please ? ... Hi @maryamait123! This...
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