1

I am trying to authenticate and create a Content Hub client using CH Javascript SDK based on this document

I have installed the npm package as described in this document

I am getting the below error on compilation.

error - ./node_modules/@sitecore/sc-contenthub-webclient-sdk/dist/clients/upload-client.js:17:0
Module not found: Can't resolve 'form-data'
null
Error: Cannot find module 'form-data'
Require stack:
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\@sitecore\sc-contenthub-webclient-sdk\dist\clients\upload-client.js       
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\@sitecore\sc-contenthub-webclient-sdk\dist\clients\content-hub-client.js  
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\.next\server\pages\about.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\next-server\server\require.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\next-server\server\load-components.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\next-server\server\api-utils.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\next-server\server\next-server.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\server\next.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\server\lib\start-server.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\cli\next-dev.js
- D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\bin\next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.mod._resolveFilename (D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\next\dist\build\webpack\require-hook.js:4:1855)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (D:\Work\Blog Materials\JAMStack\Nextjs\my-photo-blog\node_modules\@sitecore\sc-contenthub-webclient-sdk\dist\clients\upload-client.js:17:37)
    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)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\@sitecore\\sc-contenthub-webclient-sdk\\dist\\clients\\upload-client.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\@sitecore\\sc-contenthub-webclient-sdk\\dist\\clients\\content-hub-client.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\.next\\server\\pages\\about.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\next-server\\server\\require.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\next-server\\server\\load-components.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\next-server\\server\\api-utils.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\next-server\\server\\next-server.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\server\\next.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\server\\lib\\start-server.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\cli\\next-dev.js',
    'D:\\Work\\Blog Materials\\JAMStack\\Nextjs\\my-photo-blog\\node_modules\\next\\dist\\bin\\next'
  ]
}

Have you seen this error? How can I resolve this?

1
  • I should clarify that I am trying to use CH Javascript SDK from nextjs application. Commented Jul 29, 2021 at 12:06

1 Answer 1

0

I resolved this issue by running the below npm command

npm install --save form-data

It seems CH Javascript SDK installation had not included this this dependency. When I installed SDK there was no indication that form-data module is missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.