Deploy initialization uses pnpm instead of npm by default

  • https://mocha-docs-next.netlify.app/
  • No DNS issues
  • Ask Netlify and Support Guides did not provide info :frowning:

Summary

For some reason, it appears our Netlify deploys are using pnpm instead of npm in their initialization. We have not used pnpm locally in our project, and I can’t find any pnpm files or logs that indicate why Netlify is using pnpm. We do have a package-lock.json file so we expect npm to be used by default.

We didn’t notice this until Netlify deploys started failing. We can only reproduce the issue locally when using pnpm. When using npm, the build command npm run docs works fine. pnpm install does work locally and in deploys, but the following build command fails when pnpm is used, and that’s been the case since March 18.

We are considering adding "packageManager": "npm@..." to our package.json to “force” Netlify to use npm, but we’re curious why we’re seeing this behavior in the first place.

Ref Manage build dependencies | Netlify Docs:

npm comes preinstalled with Node.js, so any build scripts using npm run will work automatically. By default, if your site’s repository does not include a yarn.lock , pnpm-lock.yaml or bun.lockb file, we will run npm install to install the dependencies listed in your package.json .

Our repo: mochajs/mocha: :hot_beverage: simple, flexible, fun javascript test framework for node.js & the browser

Our issue: :hammer_and_wrench: Repo: New site isn’t deployed · Issue #5315 · mochajs/mocha

Our workaround: chore: “Force” Netlify to use npm to build new site by mark-wiemer · Pull Request #5319 · mochajs/mocha

Config and logs

netlify.toml:

[build]
  command = "npm run docs"
  publish = "docs/_site/"

[build.environment]
  DEBUG = "mocha:docs*"
  NODE_VERSION = "16"
  RUBY_VERSION = "2.7.2"

[context.deploy-preview]
  command = "npm run docs"
  publish = "docs/_site/"

Logs:

3:45:42 PM: Build ready to start
3:45:54 PM: build-image version: 59029cc38debec12b365d8cde2431251b878d6bf (focal)
3:45:54 PM: buildbot version: bb1ad402dcdb036fd1e0d06fdfff977602f794a0
3:45:54 PM: Building without cache
3:45:55 PM: Starting to prepare the repo for build
3:45:55 PM: No cached dependencies found. Cloning fresh repo
3:45:55 PM: git clone --filter=blob:none https://github.com/mochajs/mocha
3:45:55 PM: Preparing Git Reference refs/heads/docs-next
3:45:57 PM: Custom publish path detected. Proceeding with the specified path: 'docs-next/dist'
3:45:57 PM: Custom build command detected. Proceeding with the specified command: 'npm run docs'
3:45:57 PM: Starting to install dependencies
3:45:58 PM: mise python@3.13.2   install
3:45:58 PM: mise python@3.13.2   download cpython-3.13.2+20250317-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
3:45:58 PM: mise python@3.13.2   extract cpython-3.13.2+20250317-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
3:45:59 PM: mise python@3.13.2   python --version
3:45:59 PM: mise python@3.13.2   Python 3.13.2
3:45:59 PM: mise python@3.13.2 ✓ installed
3:45:59 PM: Python version set to 3.13
3:46:00 PM: Collecting pipenv
3:46:00 PM:   Downloading pipenv-2024.4.1-py3-none-any.whl.metadata (17 kB)
3:46:00 PM: Collecting certifi (from pipenv)
3:46:00 PM:   Downloading certifi-2025.1.31-py3-none-any.whl.metadata (2.5 kB)
3:46:00 PM: Collecting packaging>=22 (from pipenv)
3:46:00 PM:   Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
3:46:00 PM: Collecting setuptools>=67 (from pipenv)
3:46:00 PM:   Downloading setuptools-76.1.0-py3-none-any.whl.metadata (6.7 kB)
3:46:00 PM: Collecting virtualenv>=20.24.2 (from pipenv)
3:46:00 PM:   Downloading virtualenv-20.29.3-py3-none-any.whl.metadata (4.5 kB)
3:46:00 PM: Collecting distlib<1,>=0.3.7 (from virtualenv>=20.24.2->pipenv)
3:46:00 PM:   Downloading distlib-0.3.9-py2.py3-none-any.whl.metadata (5.2 kB)
3:46:00 PM: Collecting filelock<4,>=3.12.2 (from virtualenv>=20.24.2->pipenv)
3:46:00 PM:   Downloading filelock-3.18.0-py3-none-any.whl.metadata (2.9 kB)
3:46:00 PM: Collecting platformdirs<5,>=3.9.1 (from virtualenv>=20.24.2->pipenv)
3:46:00 PM:   Downloading platformdirs-4.3.6-py3-none-any.whl.metadata (11 kB)
3:46:00 PM: Downloading pipenv-2024.4.1-py3-none-any.whl (3.0 MB)
3:46:01 PM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 69.0 MB/s eta 0:00:00
3:46:01 PM: Downloading packaging-24.2-py3-none-any.whl (65 kB)
3:46:01 PM: Downloading setuptools-76.1.0-py3-none-any.whl (1.2 MB)
3:46:01 PM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 77.7 MB/s eta 0:00:00
3:46:01 PM: Downloading virtualenv-20.29.3-py3-none-any.whl (4.3 MB)
3:46:01 PM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 187.6 MB/s eta 0:00:00
3:46:01 PM: Downloading certifi-2025.1.31-py3-none-any.whl (166 kB)
3:46:01 PM: Downloading distlib-0.3.9-py2.py3-none-any.whl (468 kB)
3:46:01 PM: Downloading filelock-3.18.0-py3-none-any.whl (16 kB)
3:46:01 PM: Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
3:46:01 PM: Installing collected packages: distlib, setuptools, platformdirs, packaging, filelock, certifi, virtualenv, pipenv
3:46:03 PM: Successfully installed certifi-2025.1.31 distlib-0.3.9 filelock-3.18.0 packaging-24.2 pipenv-2024.4.1 platformdirs-4.3.6 setuptools-76.1.0 virtualenv-20.29.3
3:46:03 PM: [notice] A new release of pip is available: 24.3.1 -> 25.0.1
3:46:03 PM: [notice] To update, run: pip install --upgrade pip
3:46:03 PM: Attempting Ruby version 2.7.2, read from environment
3:46:04 PM: Using Ruby version 2.7.2
3:46:04 PM: Started restoring cached go cache
3:46:04 PM: Finished restoring cached go cache
3:46:06 PM: go version go1.19.13 linux/amd64
3:46:07 PM: Using PHP version 8.0
3:46:08 PM: Downloading and installing node v20.19.0...
3:46:08 PM: Downloading https://nodejs.org/dist/v20.19.0/node-v20.19.0-linux-x64.tar.xz...
3:46:09 PM: Computing checksum with sha256sum
3:46:09 PM: Checksums matched!
3:46:11 PM: Now using node v20.19.0 (npm v10.8.2)
3:46:11 PM: Enabling Node.js Corepack
3:46:11 PM: Started restoring cached build plugins
3:46:11 PM: Finished restoring cached build plugins
3:46:11 PM: Started restoring cached corepack dependencies
3:46:11 PM: Finished restoring cached corepack dependencies
3:46:11 PM: No pnpm workspaces detected
3:46:11 PM: Started restoring cached node modules
3:46:11 PM: Finished restoring cached node modules
3:46:12 PM: Installing npm packages using pnpm version 10.6.3
3:46:12 PM: Lockfile is up to date, resolution step is skipped
3:46:12 PM: Progress: resolved 1, reused 0, downloaded 0, added 0
3:46:12 PM: Packages: +539
3:46:12 PM: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3:46:13 PM: Progress: resolved 539, reused 0, downloaded 131, added 131
3:46:14 PM: Progress: resolved 539, reused 0, downloaded 492, added 492
3:46:15 PM: Progress: resolved 539, reused 0, downloaded 539, added 539, done
3:46:15 PM: dependencies:
3:46:15 PM: + @astrojs/check 0.9.4
3:46:15 PM: + @astrojs/starlight 0.28.6
3:46:15 PM: + astro 4.16.10
3:46:15 PM: + astro-og-canvas 0.5.4
3:46:15 PM: + debug 4.3.7
3:46:15 PM: + needle 3.3.1
3:46:15 PM: + sharp 0.32.6
3:46:15 PM: + starlight-package-managers 0.7.0
3:46:15 PM: + typescript 5.6.3
3:46:15 PM: ╭ Warning ─────────────────────────────────────────────────────────────────────╮│                                                                              ││   Ignored build scripts: esbuild, sharp.                                     ││   Run "pnpm approve-builds" to pick which dependencies should be allowed     ││   to run scripts.                                                            ││                                                                              │╰──────────────────────────────────────────────────────────────────────────────╯
3:46:15 PM: Done in 3.3s using pnpm v10.6.3
3:46:15 PM: npm packages installed using pnpm
3:46:16 PM: Successfully installed dependencies
3:46:16 PM: Starting build script
3:46:17 PM: Detected 1 framework(s)
3:46:17 PM: "astro" at version "4.16.10"
3:46:17 PM: Section completed: initializing

The build logs aren’t really “suspicious” or problematic, and are not included here as I am a new user and I’ve hit my character limit :smiley:

Our attempted workaround with the "packageManager": "npm@..." prop in package.json worked for our Deploy Preview but not for Production, despite them using the same repo, same netlify.toml, and same deploy settings. The Production deploys still use pnpm as logged above.

Hi, please consider this resolved! We found we were deploying from our docs-next branch, not our main branch. Our docs-next branch does have a pnpm.yaml file that I didn’t notice earlier. Netlify is working as expected :slight_smile: