Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Get SyntaxError during scanner run #1379

Closed
kumo2kumo opened this issue Mar 7, 2024 · 3 comments
Closed

[BUG]Get SyntaxError during scanner run #1379

kumo2kumo opened this issue Mar 7, 2024 · 3 comments

Comments

@kumo2kumo
Copy link

kumo2kumo commented Mar 7, 2024

Description:
I scanned my code with Salesforce Code Analyzer for security review and got SyntaxError.

run: sf scanner run --format=csv --outfile=CodeAnalyzerGeneral.csv --target="./" --category="Security"
error: SyntaxError: Error parsing C:\Users\<username>\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\node_modules\simple-swizzle\package.json: Unexpected token '', ""... is not valid JSON

Steps To Reproduce:

  1. update latest version of the CLI, by sf update.
  2. install by sf plugins install @salesforce/sfdx-scanner.
  3. change to the top-level directory of my code and metadata.
  4. run sf scanner run --format=csv --outfile=CodeAnalyzerGeneral.csv --target="./" --category="Security"
  5. got error SyntaxError: Error parsing C:\Users\<username>\AppData\Local\sf\node_modules\@salesforce\sfdx-scanner\node_modules\simple-swizzle\package.json: Unexpected token '', ""... is not valid JSON

follwed by salesforce guide

Desktop:

  • OS : windwos 11
  • Code Analyzer version: 3.21.0
  • Salesforce CLI version: @salesforce/cli/2.30.8 win32-x64 node-v20.11.1
  • node version: v20.11.1

Workaround:

  • I tried doing it with a different project code and ran into the same error.
  • The version of node was 18, so I upgraded it to v20.11.1.
@stephen-carter-at-sf
Copy link
Collaborator

Hello @kumo2kumo . I am unable to reproduce this error. Can you please first try updating to our latest-beta to see if the issue happens there as well. That is, do the following:

sf plugins uninstall @salesforce/sfdx-scanner
sf plugins install @salesforce/sfdx-scanner@latest-beta

then run your command.

If you still get an error, can you please copy/paste the contents of the C:\Users<username>\AppData\Local\sf\node_modules@salesforce\sfdx-scanner\node_modules\simple-swizzle\package.json file here as a comment.

@kumo2kumo
Copy link
Author

Hi, @stephen-carter-at-sf. Thanks for your reply.
I did the following commands as you told me and it worked!

sf plugins uninstall @salesforce/sfdx-scanner
sf plugins install @salesforce/sfdx-scanner@latest-beta

Thank you very much for your help.

@stephen-carter-at-sf
Copy link
Collaborator

Great. Closing this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants