node.jswordpressgutenberg-blocks

npm start resulting in Wordpress error blocks-manifest.php "no-such-file-or-directory"


-update- I tried using "npm run build" instead and that worked OK - a workaround, but a pain having to remember running it each time I make a change during testing/development.


I have used the "NPX @wordpress/create-block@latest" command and "NPM start" to scaffold a number of demo blocks as part of learning how to create custom blocks.

A couple of weeks ago a problem came up - the create part worked fine, but now when I then run the NPM start I get an error message that the block-manifest.php file is missing. "Warning: require(C:\Users\steev\Local Sites\new-bare-site\app\public\wp-content\plugins\todo-list/build/blocks-manifest.php): Failed to open stream: No such file or directory in C:\Users\steev\Local Sites\new-bare-site\app\public\wp-content\plugins\todo-list\todo-list.php on line 34"

The file is there before the NPM command is run. The full error page is attached. NPM runs successfully with no error messages.

I am running on Windows 10, with the localwp.com Wordpress environment. I have re-installed Localwp, Node.JS (and Chocolatey as well) and created a clean Wordpress site on Localwp.

Any help appreciated (as I have run out of ideas and am not expert in this and it is driving me mad) Screen capture of test site error message


Solution

  • I found an article that explain the meaning of the new blocks-manifest.php file

    This article

    I guess there is presently a bug in the wordpress (or webpack) scripts, the npm start script remove blocks-manifest.php file from the build firectory.

    In the meantime if you want to continue to work on your block until the bug is fixed, you can modify the main plugin file and register your blocks one by one in the old way like this:

    function create_block_block_toto_block_init() {
        register_block_type( __DIR__ . '/build/toto1' );
        register_block_type( __DIR__ . '/build/toto2' );
    }
    add_action( 'init', 'create_block_block_toto_block_init' );
    

    It will work, blocks-manifest.php will be ignored