Closed iamleese closed 2 years ago
Hey @iamleese Thanks for reporting this! Actually, we have merged this repo to woocommerce/woocommerce
recently and we have also fixed this bug here. Could you clone woocommerce and run the following commands to see if it works for you:
pnpm install
pnpm nx create-wc-extension woocommerce-admin
If you're still facing the issue, please free feel to file an issue there. I'm going to close this one. Thank you!
Describe the bug
When running create-wc-extension, ERR_REQUIRE_ESM Error is thrown
To Reproduce
npm run create-wc-extension
Actual behavior:
The Following Error is thrown: Error [ERR_REQUIRE_ESM]: require() of ES Module {wp_directory_path}/plugins/woocommerce-admin/node_modules/.pnpm/chalk@5.0.1/node_modules/chalk/source/index.js from {wp_directory_path}/plugins/woocommerce-admin/bin/starter-pack/starter-pack.js not supported. Instead change the require of index.js in {wp_directory_path}/plugins/woocommerce-admin/bin/starter-pack/starter-pack.js to a dynamic import() which is available in all CommonJS modules. at Object. (/ {wp_directory_path}/plugins/woocommerce-admin/bin/starter-pack/starter-pack.js:4:15) {
code: 'ERR_REQUIRE_ESM'
}
Expected behavior
Welcome message and extension instructions should appear.
My Solution
In the package.json, add
"type": "module"
In /bin/starter-pack/starter-pack.js, use import instead of require() and define the filename and dirname constants.