I started to use pnpm in one of my sites and made the necessary change for it to work but the build is failing which was not the case before moving to pnpm
Here’s the log of the most recent build
11:19:05 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:18:37 AM: Netlify Build
11:18:37 AM: ────────────────────────────────────────────────────────────────
11:18:37 AM:
11:18:37 AM: ❯ Version
11:18:37 AM: @netlify/build 29.12.1
11:18:37 AM:
11:18:37 AM: ❯ Flags
11:18:37 AM: baseRelDir: true
11:18:37 AM: buildId: 648c28cd2c8d36506e0da5fb
11:18:37 AM: deployId: 648c28cd2c8d36506e0da5fd
11:18:37 AM:
11:18:37 AM: ❯ Current directory
11:18:37 AM: /opt/build/repo
11:18:37 AM:
11:18:37 AM: ❯ Config file
11:18:37 AM: /opt/build/repo/netlify.toml
11:18:37 AM:
11:18:37 AM: ❯ Context
11:18:37 AM: deploy-preview
11:18:37 AM:
11:18:37 AM: ❯ Installing plugins
11:18:37 AM: - @netlify/plugin-lighthouse@4.1.1
11:18:37 AM: - @netlify/plugin-nextjs@4.37.4
11:18:53 AM:
11:18:53 AM: ❯ Using Next.js Runtime - v4.37.4
11:18:53 AM:
11:18:53 AM: ❯ Loading plugins
11:18:53 AM: - @netlify/plugin-lighthouse@4.1.1 from Netlify app
11:18:54 AM:
11:18:54 AM: @netlify/plugin-nextjs (onPreBuild event)
11:18:54 AM: ────────────────────────────────────────────────────────────────
11:18:54 AM:
11:18:54 AM: No Next.js cache to restore.
11:18:54 AM: Netlify configuration property build.environment.NEXT_PRIVATE_TARGET value changed.
11:18:54 AM:
11:18:54 AM: (@netlify/plugin-nextjs onPreBuild completed in 20ms)
11:18:54 AM:
11:18:54 AM: build.command from netlify.toml
11:18:54 AM: ────────────────────────────────────────────────────────────────
11:18:54 AM:
11:18:54 AM: $ pnpm run build
11:18:55 AM: > pokeref@1.0.0 build /opt/build/repo
11:18:55 AM: > next build
11:18:56 AM: - warn You have enabled experimental feature (appDir) in next.config.js.
11:18:56 AM: - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
11:18:56 AM: - warn No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
11:18:56 AM: - info Skipping linting
11:18:56 AM: - info Checking validity of types...
11:19:02 AM: - info Creating an optimized production build...
11:19:03 AM: > [PWA] Compile client (static)
11:19:03 AM: > [PWA] Auto register service worker with: /opt/build/repo/node_modules/.pnpm/next-pwa@5.6.0_wrtyfo6nduxtsfzuevf3bubmxq/node_modules/next-pwa/register.js
11:19:03 AM: > [PWA] Service worker: /opt/build/repo/public/sw.js
11:19:03 AM: > [PWA] url: /sw.js
11:19:03 AM: > [PWA] scope: /
11:19:03 AM: > [PWA] Fallback to precache routes when fetch failed from cache or network:
11:19:03 AM: > [PWA] document (page): /_offline
11:19:03 AM: > [PWA] Compile server
11:19:03 AM: > [PWA] Compile server
11:19:03 AM: > [PWA] Failed to build fallback worker
11:19:03 AM: asset fallback-TrXG3Gnk4xOnjneTrJbdE.js 0 bytes [emitted] [minimized] (name: main)
11:19:03 AM: ERROR in main
11:19:03 AM: Module not found: Error: Can't resolve 'babel-loader' in '/opt/build/repo'
resolve 'babel-loader' in '/opt/build/repo'
11:19:03 AM: Parsed request is a module
11:19:03 AM: using description file: /opt/build/repo/package.json (relative path: .)
11:19:03 AM: resolve as module
11:19:03 AM: looking for modules in /opt/build/repo/node_modules
11:19:03 AM: single file module
11:19:03 AM: using description file: /opt/build/repo/package.json (relative path: ./node_modules/babel-loader)
11:19:03 AM: no extension
11:19:03 AM: /opt/build/repo/node_modules/babel-loader doesn't exist
.js
11:19:03 AM: /opt/build/repo/node_modules/babel-loader.js doesn't exist
/opt/build/repo/node_modules/babel-loader doesn't exist
/opt/build/node_modules doesn't exist or is not a directory
/opt/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
11:19:03 AM: webpack 5.74.0 compiled with 1 error in 256 ms
11:19:03 AM: ELIFECYCLE Command failed with exit code 255. (https://ntl.fyi/exit-code-255)
11:19:03 AM:
11:19:03 AM: build.command failed
11:19:03 AM: ────────────────────────────────────────────────────────────────
11:19:03 AM:
11:19:03 AM: Error message
11:19:03 AM: Command failed with exit code 1: pnpm run build (https://ntl.fyi/exit-code-1)
11:19:03 AM:
11:19:03 AM: Error location
11:19:03 AM: In build.command from netlify.toml:
11:19:03 AM: pnpm run build
11:19:03 AM:
11:19:03 AM: Resolved config
11:19:03 AM: build:
11:19:03 AM: command: pnpm run build
11:19:03 AM: commandOrigin: config
11:19:03 AM: environment:
11:19:03 AM: - NEXT_POKEMONTCG_API_KEY
11:19:03 AM: - NEXT_PUBLIC_FIREBASE_API
11:19:03 AM: - NEXT_PUBLIC_FIREBASE_APP
11:19:03 AM: - REVIEW_ID
11:19:03 AM: - NEXT_PRIVATE_TARGET
11:19:03 AM: publish: /opt/build/repo/.next
11:19:03 AM: publishOrigin: config
11:19:03 AM: plugins:
11:19:03 AM: - inputs: {}
11:19:03 AM: origin: ui
11:19:03 AM: package: '@netlify/plugin-lighthouse'
11:19:03 AM: - inputs: {}
11:19:03 AM: origin: config
11:19:03 AM: package: '@netlify/plugin-nextjs'
11:19:05 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:19:05 AM: Failing build: Failed to build site
11:19:05 AM: Finished processing build request in 58.971s
2:24:24 PM: [ERROR] Deploy logs are currently unavailable. We are working on resolving the issue.
Here’s my netlify.toml file:
[build]
command = "pnpm run build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"
Do I need to install something to make the build work with pnpm ?