2

I have installed the latest SXA CLI (@sxa/CLI) on a development computer. When I run "sxa init" I get:

SyntaxError: The requested module 'file:///D:/XXXXx/AppData/Roaming/npm/node_modules/@sxa/CLI/util/configHelper.js' does not provide an export named 'hasInstalledModule'

However, when I look at that referenced file, I see it

import fs from "fs";
import path from "path";
const SERVER_CONF = path.resolve(__dirname,`../config/server.json`);

export function hasInstalledModules() {
    return fs.existsSync(path.join(process.cwd(), 'node_modules'));
}
export async function readConfig(){
    let configValue = await fs.readFileSync(path.resolve(process.cwd(), SERVER_CONF), 'utf-8');
    return JSON.parse(configValue);
}
export async function writeConfig(data){
    await fs.writeFileSync(path.resolve(process.cwd(), SERVER_CONF), JSON.stringify(data));
}
export async function getServerUrl(){
    let config = await readConfig();
    return config.serverUrl;
}

What am I missing? I recall there was a specific version of node.js that was required for the SXA CLI, has this changed?

1
  • What version of SXA, npm, and node are using? Oct 9 '20 at 0:03
1

I filed a case with Sitecore a week ago, but as of today, it is still unresolved.

Hover, I found that by deleting the "export" keyword from each function, and then adding an export at the end of the file with the list of functions, SXA CLI will now run.

I also found that I had to rename gulfile.babel.js to gulpfile.js, because the SXA CLI was saying that gulpfile.js was missing.

Now I need to figure out why other SXA CLI commands do not appear to be doing anything, even after configuring it.

0

I was able to get this working by changing this function in the configHelper.js file from this:

export function hasInstalledModules() {
    return fs.existsSync(path.join(process.cwd(), 'node_modules'));
}

to this:

export async function hasInstalledModules() {
    return fs.existsSync(path.join(process.cwd(), 'node_modules'));
}

Just needed the async in front of function. Not certain if it was left off intentionally, but everything seems to be working fine as of now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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