#addAbortListener import broken on NuxtHub deployment

30 messages · Page 1 of 1 (latest)

wise mango
#

ISSUE FIXED

  • Update all dependencies to newest versions. Especially nuxthub/core and nuxt
  • Add an enviroment variable to your deployment either in nuxthub or directly in cloudflare:
    Type: text, Name: NODE_VERSION, Value: 23
    [log] [nuxi] Nuxt 3.15.4 with Nitro 2.10.4
19:18:55.348    [error] The requested module 'node:events' does not provide an export named 'addAbortListener'
19:18:55.349      import {addAbortListener} from 'node:events';
19:18:55.349      ^^^^^^^^^^^^^^^^
19:18:55.349      SyntaxError: The requested module 'node:events' does not provide an export named 'addAbortListener'
19:18:55.349      at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
19:18:55.350      at async ModuleJob.run (node:internal/modules/esm/module_job:190:5) 

Constantly fighting with the above error in my nuxthub deployment. Worked fine before but after some package update (unfortunately I am unable to track down specifically which one), this error started occuring on every deployment. Tried changing the node.js version many times to many different versions with no avail. Can't find any answers online. Any ideas?

rotund canopyBOT
#

Hi @wise mango. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

This error appears to be related to a compatibility issue between the Node.js version used in your NuxtHub deployment and the Nuxt version you're using. The addAbortListener function was introduced in Node.js v15.0.0, so it's possible that your deployment environment is using an older version of Node.js that doesn't support this feature.

Here are a few suggestions to troubleshoot and potentially resolve this issue:

  1. Check your Node.js version:
    Make sure you're using a Node.js version that supports addAbortListener. According to the Nuxt documentation, Nuxt 3 requires Node.js version 16.10 or higher.

  2. Update your dependencies:
    There was a recent issue with the db0 package that caused problems with Nuxt initialization. As mentioned in a GitHub comment, this has been fixed in the latest version of db0. Try updating your dependencies to the latest versions, especially Nuxt and its related packages.

    npm update
    # or
    yarn upgrade
    # or
    pnpm update
    
  3. Clear cache and reinstall dependencies:
    Sometimes, clearing the cache and reinstalling dependencies can resolve issues:

    npm cache clean --force
    rm -rf node_modules
    npm install
    
  4. Check your package.json:
    Ensure that your package.json file specifies the correct Node.js version in the engines field:

    "engines": {
      "node": ">=16.10.0"
    }
    
  5. Contact NuxtHub support:
    If the issue persists after trying these steps, it might be related to the specific environment provided by NuxtHub. In this case, you should contact their support team for assistance.

#

If none of these solutions work, you may need to investigate further by checking your application's code and dependencies for any recent changes that might have introduced this incompatibility.

GitHub Issue: Broken init provides some context about recent issues with Nuxt initialization, which might be related to your problem.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@wise mango Kapa.ai is still learning and improving, please let me know how I did by reacting below.

wise mango
#

@rotund canopy i tried everything you suggested and more. I tried around 25 different node.js versions that are compatible and not a single one worked which leads me to believe the issue is somwhere else.

rotund canopyBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

I apologize that the previous suggestions didn't resolve your issue. You're right that if you've tried multiple Node.js versions without success, the problem likely lies elsewhere. Let's explore some other potential causes and solutions based on the information available in the knowledge sources.

  1. Check for conflicting dependencies:
    The error you're seeing might be caused by a conflict between different versions of dependencies. You can try to identify and resolve these conflicts by running:

    npm ls node:events
    

    This will show you which packages are depending on node:events and their versions.

  2. Investigate recent updates:
    As mentioned in the GitHub issue about a similar error, there have been recent changes in Nuxt that might be related to your problem. The issue was reportedly resolved in a nightly build. You could try using the nightly version of Nuxt to see if it resolves your issue:

    npm install nuxt-nightly@3x
    
  3. Check for import protection issues:
    There have been recent changes to import protections in Nuxt. As mentioned in a GitHub pull request, a separate custodio library was introduced for import protections. Make sure you're using the latest version of Nuxt and its dependencies, which might include fixes for these issues.

  4. Examine your Nuxt configuration:
    Review your nuxt.config.js file for any custom configurations that might be causing issues. Particularly, check if you have any custom build or alias configurations that could be interfering with the module resolution.

#
  1. Create a minimal reproduction:
    If the issue persists, it would be helpful to create a minimal reproduction of the problem. As suggested in the Nuxt documentation on reporting bugs, try to reproduce the issue in a minimal Nuxt project. This can help isolate the problem and make it easier for the Nuxt team or the community to assist you.

  2. Check for NuxtHub-specific issues:
    Since you're deploying on NuxtHub, there might be platform-specific issues. Check if there are any known issues or recent changes in NuxtHub that could be affecting your deployment.

If none of these suggestions help, and given that you've already tried multiple Node.js versions, it might be worth opening a new issue on the Nuxt GitHub repository with a detailed description of your problem, including your package.json, nuxt.config.js, and a minimal reproduction if possible. The Nuxt team or community might be able to provide more specific guidance based on your particular setup.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@wise mango Kapa.ai is still learning and improving, please let me know how I did by reacting below.

real mist
#

hey, did you find the solution? I am getting the same error on nuxthub with bun and nuxt 3.16

wise mango
#

The problem is that yesterday it stopped working again after the latest nuxt update

#

And Now I can't fix it even by rolling back nuxt back 3.15.4

#

Getting really annyoed with issue. Maybe we can get together and push for an answer from the team either by creating a github issue or by asking here

real mist
#

yoyo

#

upgrade to nuxt 3.16, nuxthub to 0.8.18 and set NODE_VERSION 23

wise mango
#

Which one from the 23s?

#

There is a lot of them

#

"engines": {
"node": ">=22.14.0"
},

Currently have this one in package.json

real mist
#

just say 23

wise mango
real mist
#

go to cloudflare's deployment (or you can also change it in nuxthub admin), and set this

wise mango
#

So ENV in the nuxthub deployment itself. I'll try

#

Thank you

real mist
#

yeah it should work. just dont forget to also update nuxt and nuxthub to latest versions

#

good luck

wise mango
#

Will add an edit so people find the solution in the future.

real mist