Cannot add property 0, object is not extensible
nuxt3构建本地没问题线上突然报错,本地用的pnpm锁了rollup版本,服务器用的npm没锁,在rollup更新4.41.0 -> 4.45.0时报错
> nuxt-app@ build D:\Projects\Company\spellai-nuxt
> nuxt buildNuxt 3.17.1 with Nitro 2.11.13 nuxi 15:59:17 WARN You have disallowed robots accessing /_nuxt/**, this may prevent your site from being indexed correctly. @nuxt/robots 15:59:20 ℹ Building for Nitro preset: node-server nuxi 15:59:20
ℹ Building client... 15:59:21
ℹ vite v6.3.5 building for production... 15:59:21
ℹ ✓ 2510 modules transformed. 15:59:32 ERROR ✗ Build failed in 10.78s 15:59:32 ERROR Nuxt Build Error: Cannot add property 0, object is not extensible nuxi 15:59:32 at Array.push (<anonymous>)at ConditionalExpression.getLiteralValueAtPath (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:12270:45)at /D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:5064:30at EntityPathTracker.withTrackedEntityAtPath (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:2014:24)at LocalVariable.getLiteralValueAtPath (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:5062:33)at Identifier.getLiteralValueAtPath (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:5207:48)at BinaryExpression.getLiteralValueAtPath (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:11785:37)at IfStatement.getTestValue (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:12806:77)at IfStatement.hasEffects (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:12722:32)at IfStatement.shouldBeIncluded (/D:/Projects/Company/spellai-nuxt/node_modules/.pnpm/rollup@4.45.0/node_modules/rollup/dist/es/shared/node-entry.js:2928:62)ELIFECYCLE Command failed with exit code 1.
解决办法
npm锁定rollup版本
"devDependencies": { "rollup": "4.41.0" }