Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add PNPM support #1633

Closed
jcayzac opened this issue Jul 8, 2020 · 41 comments · Fixed by netlify/build-image#845
Closed

Feature request: Add PNPM support #1633

jcayzac opened this issue Jul 8, 2020 · 41 comments · Fixed by netlify/build-image#845
Assignees
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@jcayzac
Copy link

jcayzac commented Jul 8, 2020

Which problem is this feature request solving?

pnpm is a robust, mature dependency manager for Node.js projects, and is much faster than npm and yarn. It elegantly solves npm doppelgängers problem and has stricter module resolution, solving yarn ghost modules.

Currently, Netlify users need to use workarounds in order to use pnpm, involving altering a proper project configuration and making it less optimal.

Describe the solution you'd like

Build images should have pnpm@latest preinstalled as a global npm module.
If a pnpm-lock.yaml file is detected in the build.base folder, pnpm install --frozen-lockfile should be run instead of npm install (or even better, the install command should just be exposed as a configuration value so that people can run what they want instead of npm install).

Can you submit a pull request?

Yes No Maybe.

@jcayzac jcayzac added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jul 8, 2020
@ehmicky
Copy link
Contributor

ehmicky commented Jul 13, 2020

Hi @jcayzac,

This sounds good.

Most of this would need to be implemented in the build-image (netlify/build-image#447), not @netlify/build though. With the exception of this file which is used only by few optional plugins.

@poteirard
Copy link

poteirard commented Oct 20, 2020

For those who need a quick workaround (like me). This seems to work: https://community.netlify.com/t/using-pnpm-and-pnpm-workspaces/2759

@Jack-Works
Copy link

The trick mentioned above --prefix=/dev/null doesn't work in npm7. I prepared a new empty npm project (./empty/package.json) and use that --prefix=/empty

@hotyes
Copy link

hotyes commented Jul 2, 2021

Hi @Jack-Works, can you give more details of your solution? I am having similar issues for using pnpm with netlify, thanks

@Jack-Works
Copy link

@hotyes

netlify.toml

[build]
    command = "./scripts/netlify.sh"
[build.environment]
    NPM_FLAGS="--prefix=./scripts/empty-project/"

scripts/netlify.sh

#!/bin/bash
set -xeuo pipefail
test "$CI" = true || exit 1
npx pnpm install -r --store-dir=node_modules/.pnpm-store
# other build scripts

scripts/empty-project/package.json

{
  "description": "This is an empty project used as the destination of netlify npm install."
}

@hotyes
Copy link

hotyes commented Jul 6, 2021

@Jack-Works thanks

@bpierre
Copy link

bpierre commented Aug 27, 2021

Another option to prevent npm to do anything is to pass the --version flag:

[build.environment]
  NPM_FLAGS = "--version"
[build]
  command = "npx pnpm install --store=node_modules/.pnpm-store && npx pnpm build"

@ehmicky what would you think of adding a NETLIFY_DISABLE_NPM=true or NETLIFY_USE_NPM=false flag? It could be the way to use alternative package managers moving forward, including Yarn (NETLIFY_USE_YARN could even be deprecated in a future Ubuntu version).

@antfu
Copy link

antfu commented Oct 13, 2021

For some information, the major Vue and Vite repos have now moved to pnpm.

This is what we have to do to have pnpm work with Netlify.

https://github.com/vuejs/vue-next/blob/master/netlify.toml#L3
https://github.com/vitejs/vite/blob/main/netlify.toml#L3
https://github.com/vuejs/vitepress/blob/main/netlify.toml#L3

Even if we can't have built-in pnpm support right now, I would love to see a more elegant solution to disable the NPM installs similar to @bpierre's proposal (or even make it aware of pnpm-lock.yaml)

@arxpoetica
Copy link

Svelte is also all in on pnpm. FWIW. Would love for it to work out of box.

@rstavchansky
Copy link
Contributor

sharing some feedback we received on our docs site on the Monorepos page in support of this feature:

I would love to see pnpm workspaces documentation on this page

@ZetiMente
Copy link

Please add pnpm! Netlify is such a great product but not having pnpm by default is a pain. Especially for monorepos which is now trendy.

@KyleBlankRollins
Copy link

KyleBlankRollins commented Mar 8, 2022

We got another request on the docs site for PNPM support (also on the Monorepos page):

What is happening with PNPM support? It is rapidly becoming the go to solution for developers with monorepos, even for small solutions that have different front-end and back-end environments.

@ehowey
Copy link

ehowey commented Mar 12, 2022

Just adding a bit more fuel to the fire for supporting PNPM by default! Thank you!

@kevinkhill
Copy link

I have found this thread also in hopes of an official support method...

@rohanrajpal
Copy link

Would really appreciate pnpm support!

@einSelbst
Copy link

https://vercel.com/changelog/projects-using-pnpm-can-now-be-deployed-with-zero-configuration please follow suit

@ghostdevv
Copy link

+1

1 similar comment
@davidboom95
Copy link

+1

@wiredmatt
Copy link

The workaround works fine but it'd be cleaner to have native support for it. +1

@swyxio
Copy link
Contributor

swyxio commented Aug 28, 2022

related netlify forum thing not that it really changes anything. https://answers.netlify.com/t/using-pnpm-and-pnpm-workspaces/2759

this has been my night today. not fun
image

@Planxnx
Copy link

Planxnx commented Sep 13, 2022

+1
Well, Vercel has been supported since March 2022 🥲

@martio
Copy link

martio commented Sep 27, 2022

When will PNPM support be added? 😏

@hnrq
Copy link

hnrq commented Oct 11, 2022

+1

@lukasholzer
Copy link
Contributor

Sorry folks that you waited that long for it but I'm already working on it. Stay tuned :)

@janosh
Copy link

janosh commented Oct 17, 2022

Thanks @lukasholzer! 👍 When is the new build image going live?

@lukasholzer
Copy link
Contributor

Hey doing a graduate slow rollout to test if we are not breaking any edge cases worrying a little bit about folks that used a hacky way to install pnpm over the build command.

But it's already in progress to roll it out ;)

@hnrq
Copy link

hnrq commented Oct 17, 2022

Do I have to edit any config for using PNPM? I tried setting the build command to pnpm build, but it didn't work

@janosh
Copy link

janosh commented Oct 17, 2022

@hnrq Worked for me. Maybe you're not part of the rollout yet?

@hnrq
Copy link

hnrq commented Oct 17, 2022

@janosh probably. Tried using the same netlify.toml as you but no success 🤔

@lukasholzer
Copy link
Contributor

lukasholzer commented Oct 18, 2022

Yea I rolled it out to 20% of our starter accounts and going to increase this number now. Nothing special needs to be configured. Just like with npm (If you have a pnpm lock file we will automatically do the pnpm install).

[Edit]: Current rollout progress is on 70% of our starter accounts

If everything is going fine today I will release it to all by the end of the day (CEST)

@lukasholzer
Copy link
Contributor

@janosh nice to hear! 🥳

@lukasholzer
Copy link
Contributor

I've rolled it out to all customers now.

@matepapp
Copy link

awesome work @lukasholzer, thanks a lot! 👏

can we expect an official announcement and/or documentation?

@lukasholzer
Copy link
Contributor

For sure @matepapp we are internally already working on it!

@rstavchansky
Copy link
Contributor

Docs are updated here: https://docs.netlify.com/configure-builds/manage-dependencies/#pnpm 🎉

@rynz
Copy link

rynz commented Oct 18, 2022

Thank you so much for your hard work, this is very exciting!

@wovalle
Copy link

wovalle commented Oct 24, 2022

Small question: how do you folks handle pnpm workspaces?

I have a project with a pnpm workspace which I hadn't been able to deploy in netlify because is trying to do npm install (instead of pnpm install) when building the project.

  • I have a pnpm-lock.yaml at the root of the project
  • I created a netlify.toml file specifying to use pnpm install in the build step (copied janosh's).
  • No package-lock.json anywhere

Still netlify tries to run npm install.

Any ideas?

@lukasholzer
Copy link
Contributor

Hey you can force it with NETLIFY_USE_PNPM=true

see: #4648 (comment)

@wovalle
Copy link

wovalle commented Oct 24, 2022

Thanks that made it work!

@Anoesj
Copy link

Anoesj commented Mar 29, 2023

@lukasholzer I hesitated to open a new issue for this, but any chance that the version of pnpm that Netlify uses is heavily outdated? pnpm v8.0.0 came out this week, but Netlify still runs on v7.13.4 it seems. My builds suddenly fail after updating to pnpm 8 locally (it has a new lockfile format) and I get this message in my Netlify build output: Found pnpm version (7.13.4) that doesn't match expected ()

@lukasholzer
Copy link
Contributor

lukasholzer commented Mar 29, 2023

Hi @Anoesj thanks for reaching out.

Netlify just has a default version installed (I agree we are sadly some versions behind here) This is the version you get if you don't specify anything. But we are using Node corepack for managing package managers.

So you should be always able to install the version you want to have installed. Only if you don't specify something you get our version.

You can specify the version by specifying it via the "packageManager" property inside the package.json

See our docs for further information:
https://docs.netlify.com/configure-builds/manage-dependencies/#pnpm

real34 added a commit to front-commerce/developers.front-commerce.com that referenced this issue Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.