AWS Amplify generates runtime crash
See original GitHub issueEnvironment
- Operating System:
Windows_NT
- Node Version:
v16.13.1
- Nuxt Version:
3.0.0-27366343.1d741cb
- Package Manager:
yarn@1.22.17
- Bundler:
Vite
- User Config:
publicRuntimeConfig
,typescript
,css
,buildModules
- Runtime Modules:
-
- Build Modules:
@vueuse/nuxt@7.5.3
Reproduction
I tried to provide a minimal reproduction in this sandbox instance, although I cannot really understand how it works. Refer to https://github.com/nuxt/framework/issues/2874#issuecomment-1046285059.
I’m providing in that environment some testing configurations for the convenience of the developers, I will shut them down when the problem is solved.
Describe the bug
When using @aws-amplify/auth for connecting to an AWS Cognito user pool, nuxt provides a runtime error very hard to debug. (See below).
In general, it would be very nice to have a more informative stacktrace about these kinds of issues.
Additional context
No response
Logs
Stacktrace of the bug
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\..\repo\url' imported from C:\Users\..\repo\.nuxt\dist\server\server.mjs
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:416:11)
at moduleResolve (node:internal/modules/esm/resolve:932:10)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:111:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at $id_28e5ebab (file:///C:/Users/../repo/.nuxt/dist/server/server.mjs:13500:233) {
code: 'ERR_MODULE_NOT_FOUND'
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:23 (10 by maintainers)
Top Results From Across the Web
Monitoring - AWS Amplify Hosting
AWS Amplify emits metrics through Amazon CloudWatch and provides access logs with detailed information about each request made to your app.
Read more >AWS Amplify Crashes on Android 6 - Stack Overflow
The basic problem here is that the app is trying to reference a class which doesn't exist at runtime: java.lang.
Read more >Functions - Overview - AWS Amplify Docs
Amplify CLI enables you to create, test and deploy Lambda functions with the ... Once a runtime is selected, you can select a...
Read more >AWS Amplify Auth Issues | Apple Developer Forums
... integrate AWS Amplify for authentication etc. I have followed all the steps to the letter, yet when I launch the app I...
Read more >AWS Amplify with Vue not able to configure - Laracasts
Their sample code here https://github.com/aws-samples/aws-amplify-vue is ... \@aws-amplify\cli\node_modules\gluegun\build\index.js:13 throw up; ^ Error: You ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I finally was able to solve the issue, thanks to https://github.com/nuxt/framework/discussions/2308, to https://github.com/nuxt/framework/issues/2070#issue-1059957544, and to nuxt3 docs, I’ll summarize the solution here, of which you can see a minimal reproduction in this sandbox environment.
Step 1 - Polyfill definition:
Include a polyfill like in https://github.com/nuxt/framework/issues/2070#issue-1059957544, (a typical location is
public/js/polyfill.js
, but any other is fine as long as you update the paths accordingly) with the following content:Step 2 - Polyfill inclusion:
Include the polyfill as a loaded script at the main entry point of your app, a typical example is shown here for a basic
app.vue
:Step 3 - Plugin setup:
Add the information for setting up an Amplify plugin. The following shows a typical usage for just the
Auth
module of Amplify, other can be added similarly. Note also that this steps assumes anaws-exports.ts
file at the root of your nuxt3 app containing the settings for Amplify, an example can be found in the sandbox environment at the beginning of this post, otherwise refer to the official Amplify documentation for the details.Step 4 - Transpiling/aliasing libraries:
Set the nuxt config to alias the amplify libraries of
aws-amplify
:That’s it for the setup, now it can be used in various way. Note, however, as pointed out in https://github.com/nuxt/framework/discussions/2308, that plugin dependencies might not be available at setup time, so two usages approach can be considered. I show here an example for an
authenticated
variable from mt-u in a classical vue style and in a more idiomatic composable style.Approach 1:
onMounted()
Approach 2:
composable
which can then be used in components in the following way:
I’ll close the issue here, I recommend to continue on the related discussion https://github.com/nuxt/framework/discussions/2308, in case of other issues.
Hi, I am having the exact same issue. Not only the url but several packages that come from amplify are not properly resolved.