Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-block package installation: Error: Cannot find module '@wordpress/browserslist-config #69102

Open
2 of 6 tasks
flexseth opened this issue Feb 7, 2025 · 1 comment
Open
2 of 6 tasks
Labels
[Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended

Comments

@flexseth
Copy link
Contributor

flexseth commented Feb 7, 2025

Description

When trying to run the create-block package, it's unable to scaffold the block.

Step-by-step reproduction instructions

  1. Create a temporary directory: cd && mkdir temp && cd temp
  2. Run the create-block installation script: npx @wordpress/create-block@latest sample-block

Getting the following error when trying to create a new block using the create-block package:

Error: Command failed with exit code 2: npm run build
[webpack-cli] Error: Cannot find module '@wordpress/browserslist-config'

Verions

Node version: v23.7.0
NPM version: 11.1.0

Full error details

Require stack:
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js
- /usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1394:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.loadQueries (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js:231:35)
    at Function.select (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:1163:26)
    at /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:332:29
    at Array.reduce (<anonymous>)
    at resolve (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:322:32)
    at browserslist (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:431:21)
    at Object.load (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/browserslistTargetHandler.js:70:9)
    at TARGETS.node (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/target.js:106:47) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js'
  ]
}

> [email protected] build
> wp-scripts build

    at makeError (/Users/seth/.npm/_npx/9444c7de6ab42aae/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/Users/seth/.npm/_npx/9444c7de6ab42aae/node_modules/execa/index.js:114:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async module.exports (/Users/seth/.npm/_npx/9444c7de6ab42aae/node_modules/@wordpress/create-block/lib/init-wp-scripts.js:28:2)
    at async module.exports (/Users/seth/.npm/_npx/9444c7de6ab42aae/node_modules/@wordpress/create-block/lib/scaffold.js:164:4)
    at async Command.<anonymous> (/Users/seth/.npm/_npx/9444c7de6ab42aae/node_modules/@wordpress/create-block/lib/index.js:128:6) {
  shortMessage: 'Command failed with exit code 2: npm run build',
  command: 'npm run build',
  exitCode: 2,
  signal: undefined,
  signalDescription: undefined,
  stdout: '\n> [email protected] build\n> wp-scripts build\n',
  stderr: "[webpack-cli] Error: Cannot find module '@wordpress/browserslist-config'\n" +
    'Require stack:\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js\n' +
    '- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js\n' +
    '    at Function._resolveFilename (node:internal/modules/cjs/loader:1394:15)\n' +
    '    at Function.resolve (node:internal/modules/helpers:145:19)\n' +
    '    at Object.loadQueries (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js:231:35)\n' +
    '    at Function.select (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:1163:26)\n' +
    '    at /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:332:29\n' +
    '    at Array.reduce (<anonymous>)\n' +
    '    at resolve (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:322:32)\n' +
    '    at browserslist (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:431:21)\n' +
    '    at Object.load (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/browserslistTargetHandler.js:70:9)\n' +
    '    at TARGETS.node (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/target.js:106:47) {\n' +
    "  code: 'MODULE_NOT_FOUND',\n" +
    '  requireStack: [\n' +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js',\n" +
    "    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js'\n" +
    '  ]\n' +
    '}',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
Node.js v23.7.0

Installing the packages

Enter the directory, install the scripts

cd sample-block
npm i

Result

up to date, audited 1 package in 3s

found 0 vulnerabilities

Trying to use the block

npm run start

Errors

[webpack-cli] Error: Cannot find module '@wordpress/browserslist-config'
Require stack:
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js
- /usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js
- /usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1394:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.loadQueries (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js:231:35)
    at Function.select (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:1163:26)
    at /usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:332:29
    at Array.reduce (<anonymous>)
    at resolve (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:322:32)
    at browserslist (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js:431:21)
    at Object.load (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/browserslistTargetHandler.js:70:9)
    at TARGETS.node (/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/lib/config/target.js:106:47) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js',
    '/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js'
  ]
}

Does the block work?

The block does not work...

Image

package.json

{
	"name": "sample-block",
	"version": "0.1.0",
	"description": "Example block scaffolded with Create Block tool.",
	"author": "The WordPress Contributors",
	"license": "GPL-2.0-or-later",
	"main": "build/index.js",
	"scripts": {
		"build": "wp-scripts build",
		"format": "wp-scripts format",
		"lint:css": "wp-scripts lint-style",
		"lint:js": "wp-scripts lint-js",
		"packages-update": "wp-scripts packages-update",
		"plugin-zip": "wp-scripts plugin-zip",
		"start": "wp-scripts start"
	},
	"devDependencies": {
		"@wordpress/scripts": "^30.10.0"
	}
}

Screenshots, screen recording, code snippet

No response

Environment info

Tried scaffolding the block in the plugins folder of a local WordPress install, also tried to scaffold the block into a dummy directory.

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
@flexseth flexseth added the [Type] Bug An existing feature does not function as intended label Feb 7, 2025
@Mamaduka Mamaduka added the [Tool] Create Block /packages/create-block label Feb 9, 2025
@t-hamano
Copy link
Contributor

I tested using the same Node/npm versions and was unable to reproduce this issue.

code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/node.js',
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/browserslist/index.js',
'/usr/local/lib/node_modules/@wordpress/scripts/config/webpack.config.js',
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/webpack-cli.js',
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/lib/bootstrap.js',
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack-cli/bin/cli.js',
'/usr/local/lib/node_modules/@wordpress/scripts/node_modules/webpack/bin/webpack.js'
]

From the log, it looks like you're unintentionally referencing a global path instead of a local path.

I'm not familiar with Node, so I'd appreciate feedback from others who are more knowledgeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Create Block /packages/create-block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants