[ERR_INVALID_ARG_TYPE] Problem With Yarn build

C:\laragon\www\david\wp-content\themes\david-azran>yarn build
yarn run v1.22.17
$ bud build
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at readFile (node:fs:393:10)
    at go$readFile (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:28298:14)
    at readFile (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:28295:12)
    at C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:116224:12
    at new Promise (<anonymous>)
    at readFile (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:116223:14)
    at Object._readFile (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:83424:58)
    at Object._readFile (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud-support\lib\cjs\index.js:116237:45)
    at Manifest.read (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud\lib\cjs\context\manifest.js:10:33)
    at makeContext (C:\laragon\www\david\wp-content\themes\david-azran\node_modules\@roots\bud\lib\cjs\context\index.js:31:58) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Config File:

/**

 * @typedef {import('@roots/bud').Bud} bud

 *

 * @param {bud} app

 */

module.exports = async (app) => {

  app

    /**

     * Application entrypoints

     *

     * Paths are relative to your resources directory

     */

    .entry({

      app: ['@scripts/app', '@styles/app'],

      editor: ['@scripts/editor', '@styles/editor'],

    })

    /**

     * These files should be processed as part of the build

     * even if they are not explicitly imported in application assets.

     */

    .assets('images')

    /**

     * These files will trigger a full page reload

     * when modified.

     */

    .watch('resources/views/**/*', 'app/**/*')

    /**

     * Target URL to be proxied by the dev server.

     *

     * This is your local dev server.

     */

    .proxy('http://david.loc')

    /**

     * Development URL

     */

    .serve('http://david.loc');

};

What’s the problem I have ?

You used a screenshot instead of pasting your code, error, etc. Screenshots prevent folks from being able to copy and run/test your code, make posts less searchable for other people with the same problem, and prevent assistive technologies like screen readers from working.

Please replace the screenshot used here with copied text, and avoid using screenshots in the future unless you are trying to debug something visual.

Fixed ! Sorry For this… Will not be repeated

You’ll need to run build commands from a WSL environment

What that mean I don’t understand

“Build commands” are commands that build your assets, like bud build. On a Windows machine they need to be run from the Windows Subsystem for Linux, or WSL.

Tbh I am not fan of the fact that I have to use LAMP stack.
I used laragon (LAMP) and I did setul WSL. So I can confirm, that some things that work on LAMP would not work on WAMP.

example: Acorn composer post dump command fails (workaround was to replace recommended stuff with wp acorn clear-compiled, but not sure if Everything works 100%)

In the end I ended up with something between sage 9 and 10. Something that works with LAMP and WAMP (different developers have different setups. so it is nice if it would work on multiple stacks)

I kept laravel mix, but started using acorn (to replace my custom implementation of service providers etc.).
NB! Acorn and sage 10 documentation is so bad. Tbh I regret doing switch / upgrade now (too much time was consumed).

Welcome @zimdin12! What specifically is so bad? What can we improve?

You’re more than welcome to provide constructive criticism, but currently… your post is pretty bad.

I have used sage for quite long time. I have been mostly happy with sage, but Sage 10 update is really poorly documented. Same problem with Acorn, so in the end I had to dig into acorns code. I don’t think that this needs examples, but I’ll add some anyways :slight_smile:

  • Tried to figure out, how to reconfigure assets manifest file inclusion. My solution was to override config files, but that caused other problems. So in the end my solution was to return array_replace_recursive with default config and overrided config.
  • Tried to undestand how and when service providers are being launched. adding acorn extras to composer.json didn’t work (mb because of the stack problem). In the end I found out that there were multiple options, but i didn’t get that information from the documentation.
  • Anything about bundles? I disabled these in the end.
    etc.

Second problem is with Support for WAMP stack (Bud and Acorn do include s). It really sucks that I am forced to work on WSL (not that WSL is bad, but not everybody uses it)
What didn’t work for me : Bud js (current thread) and “Roots\Acorn\ComposerScripts::postAutoloadDump” gave me some conversion error. This error triggered when I was using laragon, but it did not reproduce in WSL.

I usually don’t complain. I have really been happy for the work you have done.
But switching to Sage 10 and Acorn was bad for business for these reasons.
I try to be safe with switches like that, but I have been quite happy with sage in the past. So I jumped right into migrating to new version.

So the point of my current complaining is that it should be easier. I got my custom sage 9/10 hybrid to work, but other devs might have quite hard time. Better documentation and wider support would make using it surely better.
I love sage / bedrock. must have for any WP site. I really wish to continue loving it :smiley:

Odd to assume that we can read your mind and understand your experience without you actually communicating things to us.

I’m having a hard time understanding what you were trying to accomplish and what the problem was. Are you referring to using Mix instead of Bud?

In what context did you run into this issue? Trying to add a third party package, or one of your own?

Trying to have first party support for Windows as opposed to WSL isn’t worth it from our perspective right now. It’s our understanding that folks using Windows to do web development use WSL in order to do their jobs properly and work with the tools in the web ecosystem with the best compatibility.

I don’t mind the complaints as long as they aren’t just “this is bad”. Complaints are good. It helps us understand frustrations and figure out what we can do better.

Thanks for following up with some specifics.

Jeah I am using mix instead of bud, since bud works only in linux env. Main problem was that the config overriding wasn’t documented. I had to find it out myself trough code and testing.

I am not sure what you mean. I added Acorn to bedrock / sage site and wanted to use it in theme development. I did use illuminate support service providers before (integrated those myself). I did run into the issue when I tried to start using Acorn in sage theme. Didn’t find any working examples.
This discussion helped a lot with this problem: Acorn, Plugins, and Service Providers without Bedrock - acorn - Roots Discourse

WSL has some problems and not every dev needs it. depends so much on what you do or on what PC
I do love WSL, but I don’t want to lock the project to WSL. Front end developers might use something simpler like laragon.

I just wanted to let you know about compatibility and documentation problems.
I will report code problems differently :smiley: with code examples and descriptions :slight_smile:
I have had some problems, but I haven’t collected detailed information about the problems (In a hurry with a project -.-') so I just solved those for me, nothing too major.

Since there were problems with Documentation, then I didn’t want to report direct code problems. You do not need to chase phantom problems, mb I used something incorrectly or something like that. :slight_smile:

Clad to help. :wink:

As we don’t support Mix (even Laravel changed to Vite) – how to switch isn’t on our documentation.

Roots has an incredible community and you could’ve made a post asking how to use Mix instead and despite not supporting it and encouraging WSL alongside Bud, someone else or myself would’ve likely given you a reply within hours allowing you to work on other things in the mean time and stay productive.

Assuming you are using Acorn v2.1, this can easily be achieved by initializing the Acorn configs (which are very similar to Laravel) using:

$ wp acorn vendor:publish --tag=acorn

and changing your manifest in config/assets.php to:

'manifests' => [
    'theme' => [
        'path' => get_theme_file_path('public'),
        'url' => get_theme_file_uri('public'),
        'assets' => public_path('mix-manifest.json'),
    ]
]

You can then enqueue your assets using asset():

<?php

use function Roots\asset;

add_action('wp_enqueue_scripts', function () {
    wp_enqueue_script('vendor.js', asset('js/vendor.js')->uri(), [], null, true);
    wp_enqueue_script('app.js', asset('js/app.js')->uri(), ['vendor.js'], null, true);

    wp_add_inline_script('vendor.js', asset('js/manifest.js')->contents(), 'before');
});

For Service Providers – seeing as you implemented them into a previous Sage by yourself, I assume you are familiar with how they work in Laravel. The cool thing is they work the exact same in Acorn.

You can either add it to config/app.php under providers or you can add the provider in your composer.json as you mentioned above. Same as Laravel.

"extra": {
  "acorn": {
    "providers": [
      "App\\Providers\\ThemeServiceProvider"
    ]
  }
}

In fact, specifying acorn here is optional. If your package is not made to be Acorn specific and you’d like for it to work on Laravel as well, simply swap out extra.acorn to extra.laravel.


Writing thorough documentation for Acorn has proven to be difficult as it is literally Laravel under the hood, and Laravel’s documentation is absolutely incredible.

Want to learn more about what you can do with Acorn? Check out Laravel’s documentation.

If you want better documentation for Sage / Acorn, you are always welcome to contribute.

Instead of bottling up your frustrations and losing productivity, you could’ve simply posted a thread here asking how to do what you want to do – especially if you were failing to find an answer in your searches.

1 Like