Next.js tries to load the import as AMD, due to relative path resolution in Webpack to get this library to work you need to add the following to next.config.mjs.
const nextConfig = {
webpack: (config, { isServer }) => {
config.module.rules.push({
test: /\.js$/, // Apply this rule to .js files
include: /node_modules\/cybersource-rest-client/,
parser: {
amd: false, // Disable AMD parsing
},
});
return config;
},
};