Open sjkcodes opened 1 year ago
I guess the docusign-esign package was damaged so the src/ApiClient file no longer exists. Could you please remove the current package and reinstall the latest version in your application?
I've confirmed that I'm on the latest version 6.3.0 and the src/ApiClient file exists in node_modules
Based on my knowledge, NextJS is used as a Frontend framework, not a server-side. I found this post that addresses this issue on NextJS official page: https://nextjs.org/docs/messages/module-not-found#the-module-youre-trying-to-import-is-not-installed-in-your-dependencies
Hope this helps!
Getting the same issue here using next 14. Did you manage to get it work ?
I can confirm that nextjs has the ability the define backend api routes with a nodejs runtime.
I'm using Next and I'm getting this same exact error when migrating from the pages router to the app router.
Importing docusign-esign
in the app router (in a route.ts
file, which only executes on the server side) causes this Can't resolve 'ApiClient' Did you mean './ApiClient'?
error.
I tried this on Next 13 and Next 14 and encountered the same issue on both.
I tried to solve this by fiddling with webpack resolver aliases: (https://webpack.js.org/configuration/resolve/#resolvealias), and was able to make the error change to Can't resolve 'Configuration'
or various other modules, but was ultimately unable to make this work. Any help is appreciated
I think that the issue might come from these lines of code: https://github.com/docusign/docusign-esign-node-client/blob/e54536ac33f339fdff3fe695d774d830e333a0e1/src/index.js#L11-L18
I'm not really sure, but I think that in the pages router the else if
condition gets executed (which works), while the if
condition gets executed on the app router (which does not work)
@sjkcodes @romariclaurent I was able to fix this by adding the following to the next.config.js
file:
module.exports = {
...
experimental: {
serverComponentsExternalPackages: ['docusign-esign'],
},
}
Unfortunately, now I'm getting other errors that are preventing me from migrating to the app router, but might fix your problem!
Same issue here with Next.js 14 using pages router.
As @nicolassanmar added in Nov 7th answer serverComponentsExternalPackages
should be provided in your next.config.js
in case you want to use our SDK with Next.js. Don't forget to import docusign-esign
library with require
(CommonJS) not with import
(ESM). More can be seen in Next.js documentation about this option.
I followed what nicolassanmar said above:
@sjkcodes @romariclaurent I was able to fix this by adding the following to the
next.config.js
file:module.exports = { ... experimental: { serverComponentsExternalPackages: ['docusign-esign'], }, }
Unfortunately, now I'm getting other errors that are preventing me from migrating to the app router, but might fix your problem!
And also had "other errors" -- namely, when running npm run build
it would fail on linting (after successfully compiling). Changing my import statement from
import docusign from 'docusign-esign';
to
const docusign = require('docusign-esign');
fixed it and got my code compiling, as renanadstest suggested above.
Thanks, @nicolassanmar, for providing a solution here! I really appreciate your help in resolving this issue for our SDK users.
@sjkcodes @romariclaurent, can you please confirm if you've been able to resolve the issue you were facing, or are you still encountering problems?
@sonawane-sanket I am no longer facing issues after adding the above. However, at the very least, I think documentation should be updated to reflect this limitation. This solution was difficult to track down, and without finding it, I would not have been able to use DocuSign with NextJS.
I am facing this issue as well, can the documentation be updated to help us understand how to write a NextJS API route that uses docusign-esign? This is still unclear to me
HI there,
I'm getting
Module not found: Can't resolve 'ApiClient' in '\node_modules\docusign-esign\src'
from my API route.I see that this error is normally associated with users trying to run the client from the browser, but my code is definitely server-side.
I'm using NextJS 13.
Anyone else encountering this issue?