I have a Nuxt app with Primevue library. Running the app in dev mode is perfectly fine. However when I try to build the app for production using npm run build
. This error occurs:
Nuxt Build Error: [vite]: Rollup failed to resolve import "/Users/borisgrigorov/Dev/sgb/node_modules/@primevue/nuxt-module/dist/runtime/plugin.client" from "virtual:nuxt:/Users/borisgrigorov/Dev/sgb/.nuxt/plugins.client.mjs".
This is most likely unintended because it can break your application at runtime.
Full log stack:
Nuxt 3.14.159 with Nitro 2.10.4 4:45:12 PM
ℹ Using default Tailwind CSS file nuxt:tailwindcss 4:45:12 PM
✔ Prisma CLI is already installed. 4:45:18 PM
✔ Prisma schema file exists. 4:45:18 PM
✔ Database migrations folder exists. 4:45:18 PM
4:45:18 PM
Not migrating the database.
Generating Prisma client... 4:45:18 PM
4:45:24 PM
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (v5.22.0) to ./node_modules/@prisma/client in 190ms
Skipped installing Prisma Studio. 4:45:24 PM
WARN Slow module @prisma/nuxt took 11873.1ms to setup. 4:45:24 PM
WARN Failed to parse static properties from plugin node_modules/@primevue/nuxt-module/dist/runtime/plugin.client. ENOENT: no such file or directory, open '/Users/borisgrigorov/Dev/sgb/node_modules/@primevue/nuxt-module/dist/runtime/plugin.client' 4:45:25 PM
at async open (node:internal/fs/promises:639:25)
at async Object.readFile (node:internal/fs/promises:1242:14)
at async annotatePlugins (node_modules/nuxt/dist/index.mjs:5592:68)
at async Object.getContents (node_modules/nuxt/dist/index.mjs:4942:27)
at async processTemplate (node_modules/nuxt/dist/index.mjs:5444:22)
at async Promise.allSettled (index 0)
at async generateApp (node_modules/nuxt/dist/index.mjs:5472:3)
at async _applyPromised (node_modules/perfect-debounce/dist/index.mjs:54:10)
WARN Failed to parse static properties from plugin node_modules/@primevue/nuxt-module/dist/runtime/plugin.client. ENOENT: no such file or directory, open '/Users/borisgrigorov/Dev/sgb/node_modules/@primevue/nuxt-module/dist/runtime/plugin.client' 4:45:25 PM
at async open (node:internal/fs/promises:639:25)
at async Object.readFile (node:internal/fs/promises:1242:14)
at async annotatePlugins (node_modules/nuxt/dist/index.mjs:5592:68)
at async Object.getContents (node_modules/nuxt/dist/index.mjs:5004:26)
at async processTemplate (node_modules/nuxt/dist/index.mjs:5444:22)
at async Promise.allSettled (index 1)
at async generateApp (node_modules/nuxt/dist/index.mjs:5472:3)
at async _applyPromised (node_modules/perfect-debounce/dist/index.mjs:54:10)
ℹ Building client... 4:45:26 PM
ℹ vite v5.4.10 building for production... 4:45:26 PM
ℹ ✓ 24 modules transformed. 4:45:26 PM
ERROR x Build failed in 217ms 4:45:26 PM
ERROR Nuxt Build Error: [vite]: Rollup failed to resolve import "/Users/borisgrigorov/Dev/sgb/node_modules/@primevue/nuxt-module/dist/runtime/plugin.client" from "virtual:nuxt:/Users/borisgrigorov/Dev/sgb/.nuxt/plugins.client.mjs". 4:45:26 PM
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
at viteWarn (node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:65589:17)
at onRollupWarning (node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:65621:5)
at onwarn (node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:65284:7)
at node_modules/rollup/dist/es/shared/node-entry.js:19470:13
at Object.logger [as onLog] (node_modules/rollup/dist/es/shared/node-entry.js:21196:9)
at ModuleLoader.handleInvalidResolvedId (node_modules/rollup/dist/es/shared/node-entry.js:20085:26)
at node_modules/rollup/dist/es/shared/node-entry.js:20043:26
I tried to add the @primevie/nuxt-module to vite.build.rollipOotions.external in nuxt.config.ts, but that didn't help in any way.
My package.json:
{
"name": "sgb",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@nuxtjs/tailwindcss": "^6.12.1",
"@pinia/nuxt": "^0.6.0",
"@primevue/themes": "4.1.1",
"@prisma/nuxt": "^0.0.35",
"bcrypt": "^5.1.1",
"emailjs": "^4.0.3",
"iron-session": "^8.0.3",
"joi": "^17.13.3",
"nuxt": "^3.13.0",
"pinia": "^2.2.5",
"primeicons": "^7.0.0",
"primevue": "4.1.1",
"vue": "latest",
"vue-router": "latest"
},
"devDependencies": {
"@primevue/nuxt-module": "^4.1.1",
"@prisma/client": "^5.22.0",
"@types/bcrypt": "^5.0.2"
},
"overrides": {
"vue": "latest"
}
}
I would be thankful for any suggestions.
From the official documentation:
Nuxt modules are async functions that sequentially run when starting Nuxt in development mode using
nuxi dev
or building a project for production withnuxi build
.
Meaning your modules need to be available at build time. Try reinstalling @primevue/nuxt-module
as a regular dependency instead of as a dev dependency.