occur error when import "node:something"
Environment
- Operating System: Darwin
- Node Version: v18.20.4
- Nuxt Version: 3.12.4
- CLI Version: 3.12.0
- Nitro Version: 2.9.7
- Package Manager: [email protected]
- Builder: -
- User Config: bridge, imports, editor, target, alias, hooks, publicRuntimeConfig, head, router, axios, proxy, css, styleResources, plugins, components, buildModules, modules, analytics, svgSprite, i18n, build, sentry, server, env, serverHandlers, devServerHandlers, devServer, typescript, nitro
- Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @pinia/[email protected], [email protected], portal-vue/nuxt, ~/modules/ha.ts
- Build Modules: (), @nuxtjs/[email protected], @pinia/[email protected], @nuxt/[email protected]
Reproduction
https://github.com/kyumoon/nuxt-birdge-example/tree/test/ofetch
Describe the bug
I am currently developing in a 'bridge + webpack' environment and found an error while trying to integrate ofetch in advance for migration. The error is the same as the issue reported https://github.com/nuxt/bridge/issues/1066. closed PR: https://github.com/unjs/ofetch/pull/433
From what I have identified, imports with the 'node:' prefix do not work properly and need to be removed for the 'webpack + bridge' environment to function correctly.
Additional context
No response
Logs
No response
This may be a problem with Nuxt 2 rather than Nuxt Bridge. (as it also occurs without the nuxt bridge).
I recently discovered that this issue can be avoided by using hooks like the following.
https://stackblitz.com/edit/github-at3kju91-mr1ksdbf
import { defineNuxtConfig } from '@nuxt/bridge'
export default defineNuxtConfig({
hooks: {
'webpack:config': (configs) => {
for (const config of configs) {
if (Array.isArray(config.externals)) {
config.externals.push('node:http')
config.externals.push('node:https')
}
}
}
}
})