Can't resolve 'ApiClient'
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, next.js
- Domain
- api
Research direction
Start by reproducing the module-not-found error from app/api/revalidate/route.ts with Next 13, then inspect next.config.js and the cybersource-rest-client import. Done means the API route builds and runs without the 'ApiClient' resolution error.
Written by the indexing model from the issue text.
Description
Using the package with Next 13 causing this issue:
`Did you mean './ApiClient'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /Users/codeclouds-sourabh/Documents/essex/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/bin/node_modules, /Users/codeclouds-sourabh/Documents/essex/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/node_modules, /Users/codeclouds-sourabh/Documents/essex/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/node_modules, /Users/codeclouds-sourabh/Documents/essex/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules, /Users/codeclouds-sourabh/Documents/essex/node_modules/.pnpm/node_modules, /Users/codeclouds-sourabh/Documents/essex).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/api/revalidate/route.ts
- warn Fast Refresh had to perform a full reload due to a runtime error.`
Code Snippet
import * as cybersourceRestApi from 'cybersource-rest-client';
var instance = new cybersourceRestApi.KeyGenerationApi({
authenticationType: 'http_signature',
runEnvironment: 'cybersource.environment.SANDBOX',
merchantID,
merchantKeyId,
merchantsecretKey,
keyAlias: 'testrest',
keyPass: 'testrest',
keyFileName: 'testrest',
keysDirectory: 'Resource',
enableLog: true,
logFilename: 'cybs',
logDirectory: '../log',
logFileMaxSize: '5242880'
});
var request = new cybersourceRestApi.GeneratePublicKeyRequest();
request.encryptionType = 'RsaOaep256';
request.targetOrigin = 'http://localhost:3000';
var opts: { format: any } = { format: 'jwt' };
instance.generatePublicKey(request, opts, function (error: any, data: any, response: any) {
if (error) {
console.log('Error : ' + error);
console.log('Error status code : ' + error.statusCode);
} else if (data) {
console.log('Data : ' + JSON.stringify(data));
console.log('CaptureContext: ' + data.keyId);
}
console.log('Response : ' + JSON.stringify(response));
console.log('Response Code Of GenerateKey : ' + response['status']);
console.error(error, data);
});
}
Do you have any idea how to resolve this issue? Have tried altering the webpack config using next.config.js and that didn't fix anything. Any help is appreciated.
- Dominant language
- JavaScript
- Stars
- 43
- Forks
- 66
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CyberSource/cybersource-rest-samples-node
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
CyberSource/cybersource-rest-samples-node#66 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
CyberSource/cybersource-rest-samples-node#58 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 20/100
All issues in CyberSource/cybersource-rest-samples-node
Similar issues
-
Four problem loader browser tests fail on WindowsPossibly taken @Patriciaath999 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
juice-shop/juice-shop#3686 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
TheOdinProject/curriculum#31465 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
TurboDocx/html-to-docx#254 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day