# Error: Failed to load next.config.js

**URL:** <https://developer.squareup.com/forums/t/error-failed-to-load-next-config-js/5329>\
**Category:** Questions\
**Tags:** web-payments-sdk\
**Created:** [March 4, 2022, 5:38pm UTC](https://developer.squareup.com/forums/t/error-failed-to-load-next-config-js/5329 "2022-03-04T17:38:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bakarisoul](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@bakarisoul](https://developer.squareup.com/forums/u/bakarisoul)\
**Post date:** [March 4, 2022, 5:38pm UTC](https://developer.squareup.com/forums/t/error-failed-to-load-next-config-js/5329/1 "2022-03-04T17:38:19Z")

</div>

Good morning! I’m currently building out an integration of [React Square Web Payments SDK](https://github.com/weareseeed/react-square-web-payments-sdk) with NextJS. I’m getting a config error when running npm run dev coming from next.config.js and can’t figure out what’s causing it. I need an extra set of eyes to spot what I’m missing.

```auto
/** @type {import('next').NextConfig} */
const withTM = require('next-transpile-modules')(['@square/web-sdk', 'react-square-web-payments-sdk'])

module.exports = withTM({
  reactStrictMode: true,
  experimental: {
    esmExternals: 'loose'
  }
})

```

ready - started server on 0.0.0.0:3000, url: [http://localhost:3000](http://localhost:3000)  
error - Failed to load next.config.js, see more info here [next-config-error | Next.js](https://nextjs.org/docs/messages/next-config-error)  
Error: next-transpile-modules - an unexpected error happened when trying to resolve “@square/web-sdk”. Are you sure the name of the module you are trying to transpile is correct, and it has a package.json with a “main” or an “exports” field?  
Error: Can’t resolve ‘@square/web-sdk/package.json’ in ‘/Users/bakarisoul/squareDemo/next-webpay-afterpay’  
at getPackageRootDirectory (/Users/bakarisoul/squareDemo/next-webpay-afterpay/node\_modules/next-transpile-modules/src/next-transpile-modules.js:118:15)  
at Array.map ()  
at withTM (/Users/bakarisoul/squareDemo/next-webpay-afterpay/node\_modules/next-transpile-modules/src/next-transpile-modules.js:127:34)  
at Object. (/Users/bakarisoul/squareDemo/next-webpay-afterpay/next.config.js:4:18)  
at Module.\_compile (node:internal/modules/cjs/loader:1101:14)  
at Object.Module.\_extensions…js (node:internal/modules/cjs/loader:1153:10)  
at Module.load (node:internal/modules/cjs/loader:981:32)  
at Function.Module.\_load (node:internal/modules/cjs/loader:822:12)  
at ModuleWrap. (node:internal/modules/esm/translators:190:29)  
at ModuleJob.run (node:internal/modules/esm/module\_job:185:25)

---

<div class="post-metadata">

**Author:** ![wootmoot](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/wootmoot/32/21_2.png) [@wootmoot](https://developer.squareup.com/forums/u/wootmoot)\
**Post date:** [March 4, 2022, 5:40pm UTC](https://developer.squareup.com/forums/t/error-failed-to-load-next-config-js/5329/2 "2022-03-04T17:40:42Z")

</div>

Have you installed `@square/web-sdk` in addition to `react-square-web-payments-sdk`? I’m just thinking this might be the case since it can’t resolve the module.

I think I may have skipped over that in the tutorial video ☹

---

<div class="post-metadata">

**Author:** ![bakarisoul](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@bakarisoul](https://developer.squareup.com/forums/u/bakarisoul)\
**Post date:** [March 4, 2022, 5:42pm UTC](https://developer.squareup.com/forums/t/error-failed-to-load-next-config-js/5329/3 "2022-03-04T17:42:02Z")

</div>

I’ll try that. And add it to my suggestions list 😅
