Closed Sebashish closed 1 year ago
@johnboxall @SalesforceCommerceCloud/commerce-cloud-services can you guys please have a look into this. Thanks!
Hi @Sebashish, thanks for raising this issue! We've created an work item in our backlog for this and we'll update you when this issue is resolved and close this out :)
Hey folks,
I believe this issue is coming up because we've included nanoid
as a devDependancy
as opposed to a dependancy
:
It isn't possible to work around this using npm install nanoid
as you end up with a ERR_REQUIRE_ESM
error:
const nanoid_1 = require("nanoid");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jboxall/git/test-commerce-sdk/node_modules/nanoid/index.js from /Users/jboxall/git/test-commerce-sdk/node_modules/commerce-sdk/dist/helpers/slas.js not supported.
Instead change the require of index.js in /Users/jboxall/git/test-commerce-sdk/node_modules/commerce-sdk/dist/helpers/slas.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/jboxall/git/test-commerce-sdk/node_modules/commerce-sdk/dist/helpers/slas.js:30:18)
at Object.<anonymous> (/Users/jboxall/git/test-commerce-sdk/node_modules/commerce-sdk/dist/helpers/index.js:52:36)
at Object.<anonymous> (/Users/jboxall/git/test-commerce-sdk/node_modules/commerce-sdk/dist/index.js:34:19)
at Object.<anonymous> (/Users/jboxall/git/test-commerce-sdk/index.js:1:28) {
code: 'ERR_REQUIRE_ESM'
}
As a workaround, you can use commerce-sdk@2.7.1
before helpers that use nanoid
were introduced.
This issue has been linked to a new work item: W-12184003
Thank you for creating this issue @Sebashish. I am now closing this issue as v2.10.1 of the commerce-sdk
resolves this issue
Following this step by using node 16 LTS: https://developer.salesforce.com/docs/commerce/commerce-api/guide/api-and-sdk-demo.html
And then got this issue
Using this node version:
This could be because this is listed as a devDependency.