• Resolved hacketyapps

    (@hacketyapps)


    It appears the guide isn’t up to date since trying some of the commands to create a new extension appear broken. Even the instructions to install WooCommerce and WooCommerce-Admin seem broken or not up to date.

    When I try to create a new extension by running the following command: npm run create-wc-extension it errors out with the following message:

    internal/modules/cjs/loader.js:1102
          throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
          ^
    
    Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/hacketyapps/vvv-local/www/wordpress-one/public_html/wp-content/plugins/woocommerce-admin/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js
    require() of ES modules is not supported.
    require() of /Users/hacketyapps/vvv-local/www/wordpress-one/public_html/wp-content/plugins/woocommerce-admin/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js from /Users/hacketyapps/vvv-local/www/wordpress-one/public_html/wp-content/plugins/woocommerce-admin/bin/starter-pack/starter-pack.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
    Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/hacketyapps/vvv-local/www/wordpress-one/public_html/wp-content/plugins/woocommerce-admin/node_modules/.pnpm/[email protected]/node_modules/chalk/package.json.
    
        at new NodeError (internal/errors.js:322:7)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
        at Module.load (internal/modules/cjs/loader.js:950:32)
        at Function.Module._load (internal/modules/cjs/loader.js:790:12)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        at require (internal/modules/cjs/helpers.js:101:18)
        at Object.<anonymous> (/Users/hacketyapps/vvv-local/www/wordpress-one/public_html/wp-content/plugins/woocommerce-admin/bin/starter-pack/starter-pack.js:4:15)
        at Module._compile (internal/modules/cjs/loader.js:1085:14)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
        at Module.load (internal/modules/cjs/loader.js:950:32) {
      code: 'ERR_REQUIRE_ESM'
    }

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @hacketyapps

    We appreciate your effort towards developing a new WooCommerce extension.

    It appears the guide isn’t up to date since trying some of the commands to create a new extension appear broken. Even the instructions to install WooCommerce and WooCommerce-Admin seem broken or not up to date.

    I’d suggest submitting this point over at our idea board. This board is where our community can share their feedback or requests for change to any of our plugins or services: https://ideas.woocommerce.com/forums/133476-woocommerce

    BTW, have you checked our WooCommerce Plugin Developer Handbook?

    This tutorial from Codeable could also be helpful:
    https://www.codeable.io/blog/woocommerce-plugin-development/

    running the following command … it errors out with the following message

    As this is a development oriented topic, I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    * This specific forum is more focused on the default WooCommerce core features.

    Lastly, for direct assistance with code customizations, we recommend consulting with the WooCommerce Customizations Partners. https://woocommerce.com/customizations/

    Seems we’ve not had additional inputs on this thread. Thus, we encourage you to make use of the above resources.

    I’ll go ahead and mark the thread as closed but please feel free to create a new thread if you have further questions.

    Hi, just wanted to put it out there that I just ran into the same issue described above. I’ve looked at the provided links and checked out the Getting Started Guide (https://developer.woocommerce.com/extension-developer-guide/getting-started/) but we are running into errors there too.

    For example, your build process required me to install pnpm but then fails completely on the latest version of pnpm:

    https://github.com/woocommerce/woocommerce/issues/32885

    All we had hoped to do was add a column to one of the admin reports and it has been like pulling teeth – we are now 8+ hours in and have gotten nowhere. With the previous PHP architecture this would have taken less than an hour to accomplish. This is extremely frustrating.

    It would be really nice if you could ensure that your build process is working consistently so that people can follow your documentation successfully

    • This reply was modified 3 years, 11 months ago by kisabelle.

    Hi @kisabelle

    This topic is resolved, so if needed, would you mind creating your own topic here?

    Also, are you getting the same errors? Can you check, as stated in the error message if you’re using the Function require() instead of the import? I am asking this because require() shouldn’t be used in ES modules.

    I hope to hear from you soon, and if you’re still seeing errors, let us know what they are!

    My very best,

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘create-wc-extension’ is closed to new replies.