create-nuxt-app icon indicating copy to clipboard operation
create-nuxt-app copied to clipboard

Add PNPM to package manager choice

Open Aperrix opened this issue 6 years ago • 14 comments

Hi everyone !

Can you please add https://pnpm.js.org/en/ to the package manager choice ? NPM and Yarn are great but PNPM too 😄

PS : Use pnpx create-nuxt-app <myapp> already work 👍

But packages are installed with NPM. We need to delete :

  • package-lock.json
  • /node_modules

And do pnpm i.

EDIT (10 november) :

When the packages are installed with PNPM, it is impossible to launch the application because the deepdependencies are not correctly installed, it is necessary to use the flag --shamefully-hoist but suddenly the node_modules folder is identical to the one of NPM or Yarn and so we lose the usefulness of PNPM 😞

Aperrix avatar Oct 27 '19 08:10 Aperrix

I think current Nuxt.js doesn't support full functionalities of pnpm. @pi0 Any idea about pnpm support ?

clarkdo avatar Nov 09 '19 23:11 clarkdo

I think current Nuxt.js doesn't support full functionalities of pnpm. @pi0 Any idea about pnpm support ?

Yeah Nuxt doesn't support PNPM actually because it's necessary to use --shamefully-hoist flag so that all dependencies of Nuxt are installed correctly

Aperrix avatar Nov 10 '19 09:11 Aperrix

I agree. We plan to fix that hoist flag problem because we decided to stick with vue/webpack deps. But please wait until we change the core changes. So add option when we really support PNPM (again)

pi0 avatar Nov 11 '19 10:11 pi0

Hi, any news about this?

vue-cli currently supports pnpm by using an .npmrc file in the project root with the following content

shamefully-hoist=true

And it works fine, could this be a possible solution to use pnpm with Nuxt as well?

stefanobartoletti avatar May 26 '20 14:05 stefanobartoletti

@pi0 are there any news? :slightly_smiling_face:

bodrych avatar Feb 07 '21 20:02 bodrych

Hi @bodrych. I think we should finally add this option with 2.15 release. Can you please help trying via nuxt-edge if there are any issues with pnp?

pi0 avatar Feb 07 '21 20:02 pi0

@pi0 There was one warning during installation:

WARN Failed to find "/fsevents/2.3.2" in lockfile during hoisting. Next aliases will not be hoisted: fsevents

And then:

Cannot find module 'vue'
Cannot find module 'ufo'
Cannot find module 'node-fetch'
Cannot find module 'vue-meta'
Cannot find module 'vue-client-only'
Cannot find module 'vue-no-ssr'
Cannot find module 'vue-router'

Screenshot_2021-02-08 Screenshot I've installed the libraries and now nuxt-edge works well :slightly_smiling_face:

bodrych avatar Feb 07 '21 21:02 bodrych

Thanks for checking @bodrych. For reference, yarn2 has a compat plugin for webpack (pnp-webpack-plugin) that we used (and makes it working out of the box with 2.15). I'm wondering if there is one for pnpm too (maybe we can make same plugin compatible since logic is same it only gets enabled when process.versions.pnp is detected). If we do not ensure pnpm works out of the box and add option, it will confuse users when indirect dependencies like vue need to be manually installed

pi0 avatar Feb 07 '21 21:02 pi0

@pi0 Can we put node-linker=pnp and symlink=false to .npmrc? (https://pnpm.js.org/en/npmrc#node-linker). I do not quite understand the problem (because it works well now), but seems like we also have to inject process.versions.pnp variable somewhere in pnpm (like yarn do) to make pnp-webpack-plugin work, haven't we?

bodrych avatar Feb 07 '21 22:02 bodrych

because it works well now

Yes but as you mentioned, it works only when adding vue-app dependencies to package.json right? It is only my concern.

Can we put node-linker=pnp and symlink=false to .npmrc? (https://pnpm.js.org/en/npmrc#node-linker).

Sure we may do this when pnpm option is selected in create-nuxt-app .

pi0 avatar Feb 07 '21 22:02 pi0

it works only when adding vue-app dependencies to package.json

There's only nuxt-edge in dependencies.

bodrych avatar Feb 07 '21 22:02 bodrych

Then feel free making a PR @bodrych (we shall wait for 2.15 release to merge. also would be nice if can helping to do more tests. most importantly with indirect deps like when adding @nuxt/axios module)

pi0 avatar Feb 07 '21 22:02 pi0

Did this get merged with the 2.15 release? @pi0

kansson avatar Aug 05 '21 01:08 kansson

It would be nice if you set Only allow pnpm config, to prevent devs from using other package managers.

whenever someone runs npm install or yarn, they'll get an error instead and installation will not proceed.

loclv avatar Sep 11 '21 19:09 loclv