While trying to build out my Nuxt 3 app on Netlify, I run into this error:
12:30:30 PM: 1. Build command from Netlify app
12:30:30 PM: ────────────────────────────────────────────────────────────────
12:30:30 PM:
12:30:30 PM: $ npm run build
12:30:31 PM: > build
12:30:31 PM: > nuxt build
12:30:31 PM: [log] Nuxi 3.0.0
12:30:31 PM: [log] Nuxt 3.0.0 with Nitro 1.0.0
12:30:31 PM: [info] [nuxt:tailwindcss] Using default Tailwind CSS file from runtime/tailwind.css
12:30:32 PM: [error] [vite]: Rollup failed to resolve import "vue" from "node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/app/entry.mjs".
12:30:32 PM: This is most likely unintended because it can break your application at runtime.
12:30:32 PM: If you do want to externalize this module explicitly add it to
12:30:32 PM: `build.rollupOptions.external
Seems like the issue is from using pnpm install --shamefully-hoist
instead of npm
.
SOLVED:
I was able to fix this build error by adding PNPM_FLAGS=--shamefully-hoist
to my Environment Variables as mentioned in this solution (https://answers.netlify.com/t/nuxt-3-deploy-failed-rollup-failed-to-resolve-import-vue/77680/19) AND updating Build Setting in Netlify to use pnpm build
command instead of the default npm run build
.