Search code examples
reactjsnext.jscreate-react-apppnpm

How to create next or react project of a specific version with PNPM?


I use PNPM to create a react-app with this script :

pnpm create react-app react-app-name

and this script to create a next app :

pnpm create next-app --typescript

I was wondering how can I create a react app with specific version of 16 or a version 10 next app with PNPM ?


Solution

  • PNPM create under the hood uses dlx to bootstrap projects from a create-* or @foo/create-* starter kit.

    As same as you can specify version when using dlx, you can specify version of create you want to use as:

    > pnpm create next-app@9.3.2 next-app
    > pnpm create next-app@latest next-app
    

    However, I didn't see in version of these dependencies change when another version of template is specified. So I manually downgraded dependencies with:

    pnpm upgrade next@10 # Specifies version 10 of Next (downgrades from 13 to 10)
    

    It may also state that peer dependencies are unmeet so you can use same approach as above until dependencies for whole project are satisfied.