-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Module not found: Can't resolve '@azure/app-configuration' #1691
Comments
Hi @Dongw1126 Are you using any package bundlers like esbuild or webpack in your application? |
Next.js seems to use webpack, which tries to load the Azure modules, even if it is conditionally required. This is the same issue as #1688 |
Thanks for the quick reply. |
This is a webpack issue, where it does not ignore conditional requires. |
Thank you. |
Closing this issue for now. We will try to find a solution on this. |
@Dongw1126 Reopening this issue as I think I may found a temporary specific fix to work with frameworks like Next.js that use webpack. This is similar to the fix given in #1156.
Please try this fix and let me know. I got the following output with http://localhost:3000/api/v1/test from your test.zip project after the fix: PS: Please note that is a temporary and very specific fix tailored for your test case and the final fix (if it is possible from our end) still needs to be worked out. |
As you mentioned, modifying node_modules works fine. No more errors. |
The ideal solution would be to move the Azure-enabled code into a separate package as a oracledb plugin and optionally include it in user project. |
Thank you for the suggestion @sosoba. We will look into it. |
You can set a custom Webpack config in NextJS. There you can mark packages as external. In your /** @type {import('next').NextConfig} */
const nextConfig = {
webpack: config => {
/**
* These packages need to be added as external, else Oracle DB will try to load them due to a
* Webpack bug.
*
* See these two issues for more information:
* - https://github.com/oracle/node-oracledb/issues/1688
* - https://github.com/oracle/node-oracledb/issues/1691
**/
config.externals.push(
...[
"@azure/app-configuration",
"@azure/identity",
"@azure/keyvault-secrets",
"oci-common",
"oci-objectstorage",
"oci-secrets",
],
)
return config
},
}
export default nextConfig |
Closing this issue as there are workarounds and configuration changes available to solve the issue. However we will look to actively move the config Providers related code as a plugin in the upcoming releases |
Is it an error or a hang or a crash?
error
What error(s) or behavior you are seeing?
When I write the code below and call http://localhost:3000/api/v1/test,
I get "Module not found: Can't resolve '@azure/app-configuration'" error.
I haven't written any code related to azure and I'm getting an error even though I just added
require('oracledb')
.Please check this error.
I've also attached the minimal executable code as a zip file.
test.zip
The text was updated successfully, but these errors were encountered: