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.

exports is not defined is ES module scope - still not working

See original GitHub issue

Environment

Nuxt project info: 20:15:00


  • Operating System: Darwin
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27292434.d68318f
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: build
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/sweepy84/nuxt3

Describe the bug

A fresh nuxt3 project fails when installing ‘aws-amplify’ as a plugin.

Replication of Bug

Steps performed

  1. npx nuxi init nuxt3
  2. yarn install
  3. yarn add aws-amplify
  4. Added ‘amplify.ts’ to /plugins directory
  5. Added transpiling config to ‘nuxt.config.ts’
  6. yarn dev

Additional context

I know this was logged here https://github.com/nuxt/framework/issues/1573 and was supposed to be fixed with mlly fix but this did not solve problem for me even with latest fixes!

Logs

exports is not defined in ES module scope
  at $id_8b3bdae3 (file://./.nuxt/dist/server/server.mjs:3539:23)  
  at __instantiateModule__ (file://./.nuxt/dist/server/server.mjs:31429:9)  
  at __ssrLoadModule__ (file://./.nuxt/dist/server/server.mjs:31376:25)  
  at ssrImport (file://./.nuxt/dist/server/server.mjs:31401:13)  
  at $id_d9f142a1 (file://./.nuxt/dist/server/server.mjs:3206:37)  
  at async __instantiateModule__ (file://./.nuxt/dist/server/server.mjs:31429:3)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sweepy84commented, Nov 24, 2021

hi @danielroe - appreciate the response.

However I’m still struggling to understand how I can solve this problem so I can use Amplify (and other libraries) with Nuxt3.

For a long time module authors have been producing ESM-syntax builds but using conventions like .esm.js or .es.js, which they have added to the module field in their package.json. This hasn’t been a problem until now because they have only been used by bundlers like webpack, which don’t especially care about the file extension.

Reading the above, im confused… is the expectation for us to wait for conventions to change across the ecosystem of libraries we use?? Is there a workaround that we can use in the meantime?

I’ve tried using the transpile and alias options with no luck, just within the Amplify package there are a lot of sub packages that I try to add but breaks something else.

Would really appreciate a clear example of how this can be solved with the example repo. Obviously I’m not going to be the only person that has issues with Nuxt3 and AWS Amplify.

Many thanks!

2reactions
AXSJcommented, Nov 23, 2021

I am having the exact same issue, unable to continue project. Project-breaking bug

Read more comments on GitHub >

github_iconTop Results From Across the Web

exports is not defined in ES module scope AWS Lambda
I have removed the type: module and used require instead of import , but I keep getting the same problem. Lambda Folder Structure...
Read more >
ReferenceError: exports is not defined in ES module scope
Node version: 18. I'm trying to run my project with: node dist/index.js. My tsconfig.json "lib": ["ES5"]. "module": "CommonJS".
Read more >
aws lambda - module is not defined in ES module scope
aws lambda - ES6 module error : module is not defined in ES module scope. it is clear that aws nodejs 14. x...
Read more >
Exports is not defined in ES module scope #1573 - GitHub
The problem is in my current project but also in a newly created one, so I'm not sending my repo. I also tried...
Read more >
exports is not defined in es module scope lambda - You.com
exports is not defined in ES module scope - the reason for this error is that Node.js 18.x runtime is using ECMAScript modules...
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