0

I made a WordPress plugin with 3 blocks. The package.json looks like this:

"scripts": {
        "build": "wp-scripts build",
        "format": "wp-scripts format",
        "lint:css": "wp-scripts lint-style",
        "lint:js": "wp-scripts lint-js",
        "start": "wp-scripts start",
        "packages-update": "wp-scripts packages-update",
        "build:review-box": "wp-scripts build blocks/review-box/src/index.js --output-path=blocks/review-box/build/",
        "start:review-box": "wp-scripts start blocks/review-box/src/index.js --output-path=blocks/review-box/build/",
        "build:random-game": "wp-scripts build blocks/random-game/src/index.js --output-path=blocks/random-game/build/",
        "start:random-game": "wp-scripts start blocks/random-game/src/index.js --output-path=blocks/random-game/build/",
        "build:game-list": "wp-scripts build blocks/game-list/src/index.js --output-path=blocks/game-list/build/",
        "start:game-list": "wp-scripts start blocks/game-list/src/index.js --output-path=blocks/game-list/build/"
    },
    "dependencies": {
        "@wordpress/block-editor": "^8.0.13",
        "@wordpress/blocks": "^11.1.5",
        "@wordpress/i18n": "^4.2.4"
    },
    "devDependencies": {
        "@wordpress/scripts": "^19.2.2"
    }

When I run this:

npm run start:random-game

I only see this output and nothing else:

> [email protected] start:random-game
> wp-scripts start blocks/random-game/src/index.js --output-path=blocks/random-game/build/

Before I could use npm run start:random-game or npm run build:game-list to build and run the script for each blog and something like this happened:

asset index.js 2.93 KiB [emitted] [minimized] (name: index)
asset index.asset.php 192 bytes [emitted] (name: index)
Entrypoint index 3.12 KiB = index.js 2.93 KiB index.asset.php 192 bytes

This worked fine with before, and works great with any other Gutenberg plugin right now. What am I missing? I tried "npm install @wordpress/scripts --save-dev" to fix this but something seems broken. This is the repository: https://github.com/mtoensing/game-review-block

1 Answer 1

2

I've managed to pull and get it to run as I would expect.

$ npm run start:random-game

> [email protected] start:random-game C:\Users\...\game-review-block
> wp-scripts start blocks/random-game/src/index.js --output-path=blocks/random-game/build/

<i> [LiveReloadPlugin] Live Reload listening on port 35729
asset index.js 25.4 KiB [emitted] (name: index) 1 related asset
asset style-index.css 858 bytes [emitted] (name: style-index) (id hint: style) 1 related asset
asset index.asset.php 219 bytes [emitted] (name: index)
Entrypoint index 26.4 KiB (17.5 KiB) = style-index.css 858 bytes index.js 25.4 KiB index.asset.php 219 bytes 2 auxiliary assets
runtime modules 4.49 KiB 10 modules
orphan modules 3.61 KiB [orphan] 3 modules
javascript modules 6.11 KiB
  cacheable modules 5.79 KiB
    modules by path ./node_modules/@babel/runtime/helpers/esm/*.js 1.97 KiB 6 modules
    modules by path ./blocks/random-game/src/ 3.81 KiB
      ./blocks/random-game/src/index.js 1000 bytes [built] [code generated]
      ./blocks/random-game/src/style.scss 50 bytes [built] [code generated]
      ./blocks/random-game/src/edit.js 2.31 KiB [built] [code generated]
      ./blocks/random-game/src/save.js 491 bytes [built] [code generated]
  8 modules
css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[3].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[3].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[3].use[3]!./blocks/random-game/src/style.scss 47 bytes [built] [code generated]
webpack 5.65.0 compiled successfully in 1417 ms

I'd try the following

  1. rm -rf node_modules
  2. npm install --save-dev

If the above doesn't work check your node version - I use a node version manager that allows switching between versions seamlessly.

1
  • rm -rf node_modules did the trick!
    – Marc
    Jan 14, 2022 at 15:52

Your Answer

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

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