Skip to content

Build Scripts: npm run dev fails when the Gutenberg directory path contains spaces #80516

Closed

Description

@Mustafabharmal

Description

Running npm run dev fails when the Gutenberg repository is located inside a directory whose path contains spaces.

For example, cloning Gutenberg into a LocalWP site under Local Sites causes the development build to fail during the package cleaning step.

The failure occurs because the build scripts invoke child processes using shell: true, and the script paths are not quoted before being passed to the shell. As a result, the shell splits the path at the first space and attempts to execute an incomplete path.

Step-by-step reproduction instructions

  1. Clone the Gutenberg repository into a directory containing a space.

Example:

/Users/<username>/Local Sites/gutenberg/app/public/wp-content/plugins/gutenberg
  1. Install dependencies.
npm install
composer install
  1. Start the development build.
npm run dev

Expected behavior

The development build should start successfully regardless of whether the project path contains spaces.

Actual behavior

The build fails during the cleaning step with an error similar to:

🧹 Cleaning packages...

Error: Cannot find module '/Users/<username>/Local'

Node.js v22.x.x

❌ Dev build failed:
Command failed:
node /Users/<username>/Local Sites/.../clean.mjs --packages

The shell interprets:

/Users/<username>/Local

as the executable instead of the full script path.

Screenshots, screen recording, code snippet

gutenberg@23.6.0-rc.1 dev
npm run --workspace @wordpress/build-scripts dev --

@wordpress/build-scripts@0.0.0 dev
node ./dev.mjs

🔨 Starting development build...

🔍 Checking dependencies...

✔ All good.

🧹 Cleaning packages...
node:internal/modules/cjs/loader:1404
throw err;
^

Error: Cannot find module '/Users//Local'
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
at node:internal/main/run_main_module:36:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v22.17.1

❌ Dev build failed: Command failed: node /Users//Local Sites/gutenberg/app/public/wp-content/plugins/gutenberg/tools/build-scripts/clean.mjs --packages
npm error Lifecycle script dev failed with error:
npm error code 1
npm error path /Users//Local Sites/gutenberg/app/public/wp-content/plugins/gutenberg/tools/build-scripts
npm error workspace @wordpress/build-scripts@0.0.0
npm error location /Users//Local Sites/gutenberg/app/public/wp-content/plugins/gutenberg/tools/build-scripts
npm error command failed
npm error command sh -c node ./dev.mjs

Environment info

  • Gutenberg: 23.6.0-rc.1
  • macOS
  • LocalWP (repository located inside Local Sites)

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] Bug
    on Jul 21, 2026
  2. added
    [Status] In Progress
    on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Status] In Progress[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions