WordPress NPM仅运行生成和启动输出wp脚本启动,但不执行任何操作

时间:2022-01-09 作者:Marc

我制作了一个有3个块的WordPress插件。包裹。json如下所示:

"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"
    }
运行此操作时:

npm run start:random-game
我只看到这个输出,其他什么都看不到:

> [email protected] start:random-game
> wp-scripts start blocks/random-game/src/index.js --output-path=blocks/random-game/build/
在我可以使用npm run start:random game或npm run build:game list为每个博客构建和运行脚本之前,发生了如下情况:

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
这在以前很好用,现在在任何其他古腾堡插件上都很好用。我错过了什么?我试过了;npm安装@wordpress/scripts--保存开发”;但有些东西似乎坏了。这是存储库:https://github.com/mtoensing/game-review-block

1 个回复
最合适的回答,由SO网友:Bysander 整理而成

我已经设法拉动它,让它像我预期的那样运行。

$ 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
我想试试下面的方法

  1. rm -rf node_modules
  2. npm install --save-dev
如果上述操作不起作用,请检查您的节点版本-我使用一个允许在版本之间无缝切换的节点版本管理器。

相关推荐