Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

774
Views
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s). Type "SETX /?" for usage

I am using Windows 10. In CMD, I tried to execute the following command in my electron project:

setx GH_TOKEN "ghp_B3kYZy7OibM1Rka4Y3jLSiBUlvtSS717FhvE" npm run publish

And I got this error:

ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.

The following code is the part of content of the Package.json file:

"scripts": {
    "publish": "electron-builder build -w -p onTagOrDraft"
  }

In the tutorial I am watching, this command is entered in the Mac operating system as follows, where it works properly: enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use

setx GH_TOKEN "ghp_B3kYZy7OibM1Rka4Y3jLSiBUlvtSS717FhvE" && npm run publish

The && are necessary because there are two commands. Without the &&, the npm run publish will be passed as arguments to SETX

about 4 years ago · Juan Pablo Isaza Report

0

This error also occurs if the environment variable you're setting contains one or more spaces.

In this case, you may avoid the problem by enclosing the value in double quotes. Unlike SET, which would take the quotes to be part of the value, SETX excludes the quotes from your stored value.

The differences in space and quote handling by SET and SETX are shown in the examples below.

For SET with spaces, quotes are not needed (and if included, become part of the value):

Set a value                              View the value                              
-----------------------------            -----------------------------
C:\TEMP>set MYVAR=some value             C:\TEMP>set MY
                                         MYVAR=some value

C:\TEMP>set MYVAR="some value"           C:\TEMP>set MY
                                         MYVAR="some value"

For SETX with spaces, quotes are needed (and do not become part of the value):

Set a value                              View the value in a new window                      
-----------------------------            -----------------------------
C:\TEMP>SETX MYVAR some value
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.

C:\TEMP>SETX MYVAR "some value"          C:\TEMP>set MY
SUCCESS: Specified value was saved.      MYVAR=some value
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!