nuxt
nuxt copied to clipboard
New in 3.1.0: ERROR [worker reload] [worker init] Cannot find package 'sitemap' imported from myprojectpath\.nuxt\dev\index.mjs`
Environment
- Operating System: `Windows_NT`
- Node Version: `v16.15.0`
- Nuxt Version: `3.1.1`
- Nitro Version: `2.1.0`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `css`, `hooks`, `modules`
- Runtime Modules: `@funken-studio/[email protected]`, `@nuxtjs/[email protected]`, `@storyblok/[email protected]`
- Build Modules: `-`
Reproduction
npm run dev
with this nuxt.config.ts
:
export default defineNuxtConfig({
modules:
[
[
"@funken-studio/sitemap-nuxt-3",
{
hostname: "https://example.com"
}
],
"@nuxtjs/tailwindcss",
[
"@storyblok/nuxt",
{
accessToken: process.env.API_TOKEN,
}
]
]
}
);
Describe the bug
Nuxi 3.1.1
Nuxt 3.1.1 with Nitro 2.1.0
> Local: http://localhost:3000/
> Network: http://...
i Using Tailwind CSS from ~/assets/css/tailwind.css
i Tailwind Viewer: http://localhost:3000/_tailwind/
i Vite client warmed up in 6419ms
√ Nitro built in 1329 ms
ERROR [worker reload] [worker init] Cannot find package 'sitemap' imported from myprojectpath\.nuxt\dev\index.mjs
at new NodeError (node:internal/errors:372:5)
at packageResolve (node:internal/modules/esm/resolve:954:9)
at moduleResolve (node:internal/modules/esm/resolve:1003:20)
at defaultResolve (node:internal/modules/esm/resolve:1218:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
at link (node:internal/modules/esm/module_job:78:36)
Additional context
Works fine reproducibly with nuxt 3.0.0 Error occurs with nuxt 3.1.0 and 3.1.1
Logs
No response
This is not reproducible for me: https://stackblitz.com/edit/github-xyg9vo. I would confirm you actually have the sitemap
package installed.
I tried to make a reproducible stackblitz but did not succeed.
Some more investigation: nuxt 3.0.0 uses nitro 1.0.0, nuxt 3.1.0 uses nitro 2.0.0.
The error mentions index.mjs
.
This file indeed looks very different depending on which version of nuxt is used:
nuxt 3.0.0
import { createRoutesCache, validHttpCache } from 'file://myprojectpath/node_modules/@funken-studio/sitemap-nuxt-3/dist/runtime/cache.mjs';
import { createSitemap } from 'file://myprojectpath/node_modules/@funken-studio/sitemap-nuxt-3/dist/runtime/builder.mjs';
import { excludeRoutes } from 'file://myprojectpath/node_modules/@funken-studio/sitemap-nuxt-3/dist/runtime/routes.mjs';
nuxt 3.1.0
import * as sm from 'sitemap';
This is not reproducible for me: https://stackblitz.com/edit/github-xyg9vo. I would confirm you actually have the
sitemap
package installed.
sitemap
was not installed and it worked without in nuxt 3.0.0
.
Now it seems necessary to use it.
I added "sitemap": "7.1.1"
to the dependencies and now it works.
Is this now a bug or regression?
As I said, I can't reproduce it, so I'm assume it's an issue with your package manager, lockfile or node_modules folder rather than a regression in Nuxt. But if you can provide a reproduction I'm more than happy to reopen and investigate further.
Same with "nuxt-proxy": "0.3.12"
[worker reload] [worker init] Cannot find package 'http-proxy-middleware' imported from ...
UPD After clearing node_modules and lockfile all working.
cc: @pi0 in case this is a regression of the node_modules hoisting