Closed martinszeltins closed 7 months ago
Most likely dupe of #23984
@manniL in my case I have shamefully-hoist=true
and adding public-hoist-pattern[]=*nitropack*
did not help. It still gives me this error even after deleting node_modules and pnpm-lock file and reinstalling dependencies.
Cannot find module 'nitropack'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?
I see that with Nuxt 3.10 the "moduleResolution" has been changed from "Node" to "Bundler" which seems to be causing the issue for me. What can I do about this?
Finally found the solution to my problem, had to this this:
nuxt.config.ts
export default defineNuxtConfig({
future: {
typescriptBundlerResolution: false
}
})
@martinszeltins Weird, I can't reproduce the problem with bundler resolution + PNPM on my end 🤔
@martinszeltins Weird, I can't reproduce the problem with bundler resolution + PNPM on my end 🤔
Honestly, no idea but I'm glad the typescriptBundlerResolution
setting fixed it. With Bundler resolution all these 3 lines were showing errors, when switching to Node the errors are gone.
import type { FetchResult } from 'nuxt/dist/app/composables/fetch.d.ts'
import type { KeysOf, PickFrom } from 'nuxt/dist/app/composables/asyncData'
import type { NitroFetchRequest, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack'
Using regular npm
and running in to the same issue as Martins.
Though for me it was for defineNuxtConfig
, import {createResolver} from "@nuxt/kit";
and more.
Workaround seems to work for now.
I got this yesterday:
[02:10:37] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.
[02:10:38] WARN [plugin node-resolve] Could not resolve import "nitropack/runtime" in A:\xxx\node_modules\.pnpm\nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1\node_modules\nuxt-auth-utils\dist\runtime\server\plugins\oauth.js using exports defined in A:\xxx\node_modules\.pnpm\nitropack@2.7.2_ioredis@5.4.1_magicast@0.3.4\node_modules\nitropack\package.json.
[02:10:38] WARN "nitropack/runtime" is imported by "node_modules/.pnpm/nuxt-auth-utils@0.1.0_magicast@0.3.4_rollup@4.18.1/node_modules/nuxt-auth-utils/dist/runtime/server/plugins/oauth.js", but could not be resolved – treating it as an external dependency.
[worker reload] [worker init] Cannot find package 'nitropack' imported from A:\xxx\.nuxt\dev\index.mjs 02:13:16
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at new NodeError (node:internal/errors:405:5)
at packageResolve (node:internal/modules/esm/resolve:916:9)
at moduleResolve (node:internal/modules/esm/resolve:973:20)
at defaultResolve (node:internal/modules/esm/resolve:1193:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
at link (node:internal/modules/esm/module_job:75:36)
I tried a lot of things, like deleting .nuxt and node_modules and reinstalling them, or installing Nitropack as a dev dependency, but what ended up fixing it was me restarting my PC. Man, I hate Windows so much. Every third problem I have is caused by it. I really have to switch to Linux soon. I cannot stand this anymore.
Yeah, the moral of the story is that you should always ask yourself this question: "Have you tried turning it off and on again?"
Environment
Stackblitz
Reproduction
https://stackblitz.com/github/martinszeltins/nuxt-nitropack?file=utils%2Fapi.ts
Describe the bug
I wanted to use
InternalApi
type from nitropack so I imported it but it is throwing me this error:I was looking at another Nuxt project where someone had done this and it resolved to this path but it is not working for me in my project.
I also tried importing form
#imports
but that did not work either. I am creating my own wrapper for useFetch() so I need to get access to nitro InternalApi type.Additional context
No response
Logs
No response