Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sdc-build-wp (CLI)
✓ npx sdc-build-wp [args]
✗ import { sdcBuildWp } from 'sdc-build-wp';
This package is primarily a Command Line Interface (CLI) tool. It's intended to be executed via `npx` or a global installation.
index.js (Main Module)
✓ import 'sdc-build-wp/index.js';
✗ require('sdc-build-wp'); // While technically works for CJS, ESM is preferred for modern Node.js environments.
For advanced programmatic scenarios, you can import or require the main `index.js` module directly, though specific exports are not documented for library-style use.
Programmatic Invocation
✓ import { spawn } from 'child_process';
spawn('npx', ['sdc-build-wp', '--watch'], { stdio: 'inherit' });
When integrating `sdc-build-wp` into a larger JavaScript/TypeScript build script, it's common practice to invoke it as a child process using Node.js's `child_process` module.
This quickstart demonstrates how to programmatically install `sdc-build-wp` in a temporary WordPress theme project and then run its `--watch` command for a short period, mimicking a development workflow.
import { spawn } from 'child_process';
import { mkdtempSync, writeFileSync, rmSync, mkdirSync, existsSync } from 'fs';
import path from 'path';
import os from 'os';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
async function runQuickstart() {
const tmpDir = mkdtempSync(path.join(os.tmpdir(), 'sdc-build-wp-quickstart-'));
const projectRoot = path.join(tmpDir, 'my-wp-theme');
console.log(`Setting up a dummy WordPress theme in: ${projectRoot}`);
mkdirSync(projectRoot, { recursive: true });
writeFileSync(path.join(projectRoot, 'style.css'), '/* Theme Name: My Test Theme */');
writeFileSync(path.join(projectRoot, 'index.php'), '<?php echo "Hello World"; ?>');
mkdirSync(path.join(projectRoot, 'src', 'js'), { recursive: true });
writeFileSync(path.join(projectRoot, 'src', 'js', 'main.js'), 'console.log("Hello from main.js");');
console.log('Installing sdc-build-wp locally...');
const installProcess = spawn('npm', ['install', 'sdc-build-wp'], {
cwd: projectRoot,
stdio: 'pipe',
});
let installOutput = '';
installProcess.stdout.on('data', (data) => { installOutput += data.toString(); });
installProcess.stderr.on('data', (data) => { installOutput += data.toString(); });
await new Promise((resolve, reject) => {
installProcess.on('close', (code) => {
if (code === 0) {
console.log('Installation complete.');
resolve();
} else {
console.error(`npm install failed with code ${code}.\nOutput:\n${installOutput}`);
reject(new Error('Installation failed'));
}
});
installProcess.on('error', reject);
});
console.log('\nRunning sdc-build-wp --watch (will run for ~15 seconds)');
const buildProcess = spawn(path.join(projectRoot, 'node_modules', '.bin', 'sdc-build-wp'), ['--watch'], {
cwd: projectRoot,
stdio: 'inherit',
env: { ...process.env },
});
console.log('--- CLI Output Start ---');
const timeoutId = setTimeout(() => {
console.log('\n--- CLI Output End ---');
console.log('Stopping sdc-build-wp --watch after 15 seconds.');
buildProcess.kill('SIGTERM');
}, 15000);
buildProcess.on('close', (code) => {
clearTimeout(timeoutId);
console.log(`sdc-build-wp process exited with code ${code}.`);
try {
rmSync(tmpDir, { recursive: true, force: true });
console.log(`Cleaned up temporary directory: ${tmpDir}`);
} catch (cleanupErr) {
console.error(`Error during cleanup: ${cleanupErr.message}`);
}
});
buildProcess.on('error', (err) => {
clearTimeout(timeoutId);
console.error(`Failed to start sdc-build-wp: ${err.message}`);
try {
if (existsSync(tmpDir)) {
rmSync(tmpDir, { recursive: true, force: true });
console.log(`Cleaned up temporary directory: ${tmpDir}`);
}
} catch (cleanupErr) {
console.error(`Error during cleanup: ${cleanupErr.message}`);
}
process.exit(1);
});
}
if (import.meta.url === path.join('file://', __filename)) {
runQuickstart().catch(error => {
console.error('Quickstart failed:', error);
process.exit(1);
});
}
sdc-build-wp --version
Errors
Common errors & fixes
sdc-build-wp: command not found
The `sdc-build-wp` executable is not found in the system's PATH. This typically happens if the package is not installed globally or `npx` is not used for execution.
fixEnsure `sdc-build-wp` is installed either globally (`npm install -g sdc-build-wp`) or within your project's `node_modules`. If local, run it via `npx sdc-build-wp` or specify the full path `./node_modules/.bin/sdc-build-wp`.
Error: Unsupported Node.js version. sdc-build-wp requires Node.js >=22.
The Node.js runtime environment being used is older than the minimum required version (v22).
fixUpgrade your Node.js version to 22 or newer. Use a Node Version Manager (e.g., `nvm install 22 && nvm use 22`) to manage multiple Node.js versions.
PHP_CodeSniffer error: The "PSR2" coding standard is not installed.
After upgrading `sdc-build-wp` (which includes PHP Code Sniffer v4), your project's PHPCS configuration might reference standards or rules that are no longer available, renamed, or require a different installation path in the new version.
fixVerify your `phpcs.xml` or similar configuration file. Ensure all referenced coding standards and sniffs are compatible with PHP Code Sniffer v4. You may need to update standard names or install additional sniffs if they are no longer bundled by default.
Audit
Dependencies
noderequiredRuntime environment requirement for executing the build process.