0

As per Sitecore document After successful installation of npm i -g @sitecore/sxa-cli, followed the below three steps to add a theme using SXA CLI:

  1. Download the Sitecore theme boilerplate.

  2. Go to Website\App_Config\Include\z.Feature.Overrides and enable the z.SPE.Sync.Enabler.Gulp.config.disabled file.

  3. Switch to the downloaded theme boilerplate folder.

Getting below error when I run sxa init

PS D:\ResourceFiles\SXABoilerplate\package> sxa init

sxa : The term 'sxa' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

sxa init

   + CategoryInfo          : ObjectNotFound: (sxa:String) [], CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

**Update 1**
Performed all the steps suggested by @Sreekrishnan. 
When run the install command "npm install -g @sitecore/sxa-cli" after uninstall, getting below error:

*D:\projects\Project name\node_modules\@sitecore\sxa-theme>npm i -g @sitecore/sxa-cli
npm ERR! Unexpected token < in JSON at position 1 while parsing near '
npm ERR! <!doctype html>
npm ERR! <htm...'
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\2087200-admin\AppData\Roaming\npm-cache\_logs\2024-05-07T11_36_44_733Z-debug.log*

Checked on "Log Files", it seems like it is looking for "json file" but it is getting HTML file. Here is Log file code:

*info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'i',
1 verbose cli   '-g',
1 verbose cli   '@sitecore/sxa-cli'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 8543f0c507bfcfea
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://www.npmjs.com/package/@sitecore/sxa-cli 1134ms (from cache)
8 silly fetchPackageMetaData error for @sitecore/sxa-cli@latest Unexpected token < in JSON at position 1 while parsing near '
8 silly fetchPackageMetaData <!doctype html>
8 silly fetchPackageMetaData <htm...'
9 timing stage:rollbackFailedOptional Completed in 2ms
10 timing stage:runTopLevelLifecycles Completed in 1181ms
11 verbose stack SyntaxError: Unexpected token < in JSON at position 1 while parsing near '
11 verbose stack <!doctype html>
11 verbose stack <htm...'*
2
  • Which Sitecore version is it ? Commented May 3 at 9:52
  • 1
    Upgrading Sitecore 9.1.1 to 10 .3. This is Sitecore 10.3 Commented May 3 at 10:03

3 Answers 3

2

It seems to me sxa-cli has not been installed.

  1. You should register Sitecore's package source to download sxa-cli package with following command:

    npm config set @sitecore:registry=https://www.npmjs.com/package

  2. And then install sxa-cli using below command:

    npm i -g @sitecore/sxa-cli

Please refer steps mentioned in https://doc.sitecore.com/xp/en/developers/sxa/93/sitecore-experience-accelerator/add-a-theme-using-sxa-cli.html for 9.3 and https://doc.sitecore.com/xp/en/developers/sxa/101/sitecore-experience-accelerator/add-a-theme-using-sxa-cli.html for 10.1 for step by step installation of theme using cli.

0

The error message "The term 'sxa' is not recognized" indicates that PowerShell cannot locate the sxa command you're trying to run

You can try multiple methods to resolve the issue

  1. Verify Installation Path: Check if the @sitecore/sxa-cli package is installed globally using npm list -g @sitecore/sxa-cli. This ensures it's accessible from any directory. If the package is installed correctly, PowerShell should recognize the sxa command.

  2. Reinstall the SXA CLI: If the above steps don't work, try reinstalling the SXA CLI. First, uninstall it: npm uninstall -g @sitecore/sxa-cli. Then, reinstall it globally: npm install -g @sitecore/sxa-cli. If still it does not work, uninstall using npm uninstall -g @sitecore/sxa-cli

  3. Install sxa cli differently using this command : npm install @sxa/[email protected] and try once.

Hope this helps!!!

0

You can check @sitecore/sxa-cli is installed properly, by navigating to folder where global node modules are installed.

%AppData%\Roaming\npm\node_modules\@sxa\cli

In case the folder is not there, you need to install it by running below command:

npm i -g @sxa/CLI

Before running above command, make sure sxa registry is there in npm config.

npm config set @sxa:registry=https://sitecore.myget.org/F/sc-npm-packages/npm/

Note: Make sure you are running above commands in a Developer Visual Studio command prompt.

Hope this helps!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.