N
Nuxt2mo ago
NicoDevs

Issue: Nuxt Bridge fails to run or build, error with unenv mock proxy

When trying to run a Nuxt 2 application with nuxt-bridge on, I get the following error:
ERROR Error: Could not load /node_modules/unenv/dist/runtime/runtime/mock/proxy.mjs (imported by node_modules/nitropack/dist/runtime/internal/error/dev.mjs): ENOENT: no such file or directory, open '/node_modules/unenv/dist/runtime/runtime/mock/proxy.mjs'
ERROR Error: Could not load /node_modules/unenv/dist/runtime/runtime/mock/proxy.mjs (imported by node_modules/nitropack/dist/runtime/internal/error/dev.mjs): ENOENT: no such file or directory, open '/node_modules/unenv/dist/runtime/runtime/mock/proxy.mjs'
So it can't find the proxy.mjs but is looking in dist/runtime/runtime/mock/proxy.mjs when in fact the file is in dist/runtime/mock/proxy.mjs Minimal repro here: https://github.com/nicodevs/bridging Any ideaon how to solve it?
GitHub
GitHub - nicodevs/bridging: Attempt to bridge a Nuxt 2 app
Attempt to bridge a Nuxt 2 app. Contribute to nicodevs/bridging development by creating an account on GitHub.
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @NicoDevs. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources, I can see that your issue with Nuxt Bridge is related to recent changes in the unenv package and its integration with Nitro. The error you're experiencing appears to be related to path resolution issues with the unenv package, specifically with the mock proxy module. This is similar to issues that have been reported in Nuxt 3 after upgrading to newer versions. From the knowledge sources, I can see that: 1. There have been significant changes to unenv with the upgrade to version 2, which has caused compatibility issues with Nitro and Nuxt as mentioned in this PR. 2. There are known issues with hoisting on unenv that have been addressed in newer versions of Nuxt with a new mocked-exports approach as noted in this PR. 3. Similar errors have been reported by users after upgrading to Nuxt 3.16.0, related to unenv dependencies as discussed in this issue. To solve this issue, you could try: 1. Manually adding unenv as a dev dependency:
npm install -D unenv
npm install -D unenv
or
yarn add -D unenv
yarn add -D unenv
2. Clean your project's dependencies and reinstall:
rm -rf node_modules .nuxt .output
npm install
rm -rf node_modules .nuxt .output
npm install
3. Make sure you're using compatible versions of Nuxt Bridge and Nitro. The knowledge sources indicate that Nuxt Bridge requires specific configurations for Nitro to work properly as documented here. 4. Check your nuxt.config.ts to ensure you have properly configured Bridge with Nitro:
import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
bridge: {
nitro: true
}
})
import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
bridge: {
nitro: true
}
})
It's worth noting that Nuxt Bridge support is being phased out in newer versions of Nuxt, as indicated by this PR which removes support for Nuxt 2/Bridge in newer versions. If these solutions don't work, you might need to consider migrating to Nuxt 3 as Bridge is a transitional solution and may have compatibility issues with the latest dependencies. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@547731342251655169> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?