Skip to content

Bug report: spfx project upgrade causes JSON.parse exception #1723

@MarksPoint

Description

@MarksPoint

Description

I was trying to upgrade our 1.10 project to 1.11 using the O365 CLI.
I simply used spfx project upgrade.
I got the following exception and the O365 CLI quit after that:

o365$ spfx project upgrade
readline.js:1086
            throw err;
            ^

SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at manifestFiles.map (/usr/local/lib/node_modules/@pnp/office365-cli/dist/o365/spfx/commands/project/base-project-command.js:126:35)

Looking at the source code in this repo I noticed the expected encoding for the [webpart].manifest.json file is UTF-8, but somehow mine was UTF-8 with BOM. I changed the encoding of the file to UTF-8 and it started working after that.

Not sure if you'd call this a bug, but at least it's for those out there that run into the same error I did.

To fix this exception using VS Code:

  • Open your project in VS Code
  • Open the manifest.json file
  • Look for the actual encoding in the bottom of the window (mine says UTF-8 with BOM)
  • Click it (the encoding)
  • Choose "Save with Encoding" from the Action menu in the top
  • Choose "UTF-8"
  • Re-run spfx project upgrade

Steps to reproduce

To reproduce this, change the encoding of the manifest.json file to UTF-8 with BOM. Then run spfx project upgrade. You should now have the same exception as mentioned above.

Expected result

Either the result should be that the command works fine with different encodings, or it should detect that the encoding is wrong and tell me that I need to change the encoding to UTF-8.

Actual result

The error mentioned above.

Environment

MacOS, running command from bash terminal inside VS Code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions