Search code examples
npmgulpphpcs

WP Rig: Error running npm run build: Cannot find "/vendor/bin/phpcs"


I've installed WP Rig on a Windows development machine running WAMPserver.

I get to Step 5 at the URL above where I need to run npm run build, and then I receive an error:

Finished 'images' after 1.91 s
[16:34:30] 'php' errored after 5.92 s
[16:34:30] Error in plugin "gulp-phpcs"
Message:
    Cannot find "C:\wamp64\www\wprig.local\wp-content\themes\wprig-master/vendor/bin/phpcs"[16:34:30] 'buildDev' errored after 5.94 s

So, I installed phpcs by navigating to /wp-content/themes/wprig-master, and running:

npm install gulp-phpcs --save-dev

Then edited composer.json to replace;

"phpcs-dev": "\"vendors/phpcs\"",

with;

"phpcs-dev": "\"node_modules/gulp-phpcs\"",

The folder C:\wamp64\www\wprig.local\wp-content\themes\wprig-master/vendor/gulp-phpcs now exists.

It contains:

enter image description here

But I still receive the following error when I run npm run build:

Message:
    Cannot find "C:\wamp64\www\wprig.local\wp-content\themes\wprig-master/node_modules/gulp-phpcs"`

Help appreciated.


Solution

  • Revert changes to composer.json file relating with the custom phpcs-dev script.

    Your composer.json should have phpcs-dev script to be:

        "phpcs-dev": "\"vendor/bin/phpcs\"",
    

    https://github.com/wprig/wprig/blob/v2.0.1/composer.json#L32

    And not

         "phpcs-dev": "\"vendors/phpcs\"",
    

    Then, run

     composer install
    

    Test that phpcs-dev runs successfully by running:

     composer phpcs-dev
    

    After taking care that the PHP dependencies are all set up the right way, proceed to installing the Javascript dependencies for WPRig by running:

    npm install