question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use AWS v3 SDK due to error: Identifier 'module' has already been declared

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.3 RootDir: /Volumes/SuperData/Sites/reelcrafter/v2-microservices Nuxt project info:


  • Operating System: Darwin
  • Node Version: v14.19.1
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: yarn@3.0.2
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-d2pz9b?file=app.vue

Describe the bug

When importing and using classes and functions from the AWS v3 SDK, the following error is thrown when loading the Nuxt app in a browser:

[nuxt] [request error] Identifier 'module' has already been declared
  at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
  at async link (internal/modules/esm/module_job.js:67:21)

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Sep 15, 2022

This is no longer reproducible on latest RC, with the new vite-node devBundler (enabled by default): https://stackblitz.com/edit/github-d2pz9b-b9tyjs.

0reactions
ffxsamcommented, Jul 7, 2022

I’ve worked around this module issue in AWS Amplify by just creating a Nuxt plugin:

plugins/graphql.client.ts

import { API } from 'aws-amplify';

export default defineNuxtPlugin(() => {
  return {
    provide: { API },
  };
});

Then whenever I want to use the API:

const { $API } = useNuxtApp();
const data = await $API.graphql(...);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Identifier 'module' has already been declared - amplify and ...
I added a ~/composables/useBucket.ts file which I used in ~/api . Same error started popping up the next day. After I moved ~/composables/ ......
Read more >
Error Handling in Modular AWS SDK for JavaScript (v3)
In this post, we cover how to use it and how it improves the error handling experience. Why did we do it? Previously,...
Read more >
Identifier has already been declared Error in JavaScript
The "Identifier has already been declared error" occurs when a variable with the same name has been declared multiple times in the same...
Read more >
Node.js v19.3.0 Documentation
A subclass of Error that indicates the failure of an assertion. ... and will throw an error for functions that have not been...
Read more >
Identifier "x" has already been declared" - Ep 11 - YouTube
Your browser can't play this video. ... How to fix "Uncaught SyntaxError: Identifier "x" has already been declared " - Ep 11.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found