imagekit-nodejs icon indicating copy to clipboard operation
imagekit-nodejs copied to clipboard

Unable to use signed urls, problems with importing crypto module

Open dovca opened this issue 3 months ago • 0 comments

Problem description

When I add signed:true to the options of client.helper.buildSrc(), I get the following error:

URL signing requires Node.js crypto module which is not available in this runtime. Please use Node.js environment for URL signing functionality.
    at createHmacSha1 (node_modules/@imagekit/nodejs/lib/crypto-utils.mjs:23:15)
    at getSignature (node_modules/@imagekit/nodejs/resources/helper.mjs:391:12)
    at Helper.buildSrc (node_modules/@imagekit/nodejs/resources/helper.mjs:79:34)

Upon further investigation, it is because the ES module is trying to call the require function, which does not exist in that context.

Please fix this error by using a static import statement instead of the dynamic require function in the ESM build of @imagekit/nodejs/lib/crypto-utils.mjs

Environment

Bundler: Vite 7.2.2 (under Nuxt 4.2.1) Node: 24.3.0 @imagekit/nodejs: 7.1.1

Reproduction

https://bolt.new/~/sb1-dslmuuah

  1. Open the linked project
  2. Switch to the code tab <>
  3. Open the Terminal tab
  4. Run node index.mjs
  5. See error in the console

dovca avatar Dec 19 '25 11:12 dovca