Package.json for payload templates installs payload 1.x

default discord avatar
slippery_jim
last month
14

I've been having some trouble with the new payload version.


Running npx create-payload-app works locally, but if you commit that project to git and run

npm install

on another computer it installs Payload 1.15.8. I think it's a peer dependency issue. Installing payload 2.0.3 doesn't quite fix it as the website template has some seeding issues afterward. Any tips on how to fix this?



Quick repro steps:


- Run

npx create-payload-app my-project -t website


- Rename node_modules to something else, i.e. node_modules_2


- Run

npm install

It should install Payload 1.15.8 instead of 2.0.3



Attached are the package*.json files

  • default discord avatar
    copypaper.
    last month

    I had the same issue! Had to run

    npx create-payload-app@latest

    for it to get the 2.0 update. If you commit your project you should have a package lock file though right?

  • default discord avatar
    slippery_jim
    last month

    @copypaper. I'm on the latest version, 0.5.0.


    The weird thing is the package-lock.json doesn't specify a version, it just says "latest", which is probably part of the issue but idk



    specifically, the payload package isn't locked in the package-lock for some reason. most of the rest are



    The problem seems to be many of the peer dependencies are specified as

    "payload": "^0.18.5 || ^1.0.0",

    , which excludes payload 2.x

  • default discord avatar
    copypaper.
    last month

    Yea I had the same issue, I had to manually set it to ^2.0.3. Then do

    npm install --force

    . Not ideal using force, but works for now

  • default discord avatar
    slippery_jim
    last month

    Ah ok Ty I missed the force option



    ah i figured out, if you install yarn before running create-payload-app it'll use yarn for dependencies instead. yarnpkg.com has a bunch of updated stuff that npm is missing

  • default discord avatar
    aaronksaunders
    last month

    we ran into the same problem and switched over to yarn, but that doesn't really comfort me as a solution

  • discord user avatar
    denolfe
    Payload Team
    last month

    create-payload-app attempts to do some detection of package managers on install. You can override with a flag --use-npm or --use-yarn.



    Interesting about the peer dependencies issue. We will look into that.

  • default discord avatar
    copypaper.
    last month

    I tried again with

    npx create-payload-app --use-npm

    and everything works correctly now @denolfe. However, if I install

    npm install @payloadcms/plugin-stripe

    , it will automatically downgrade payload to

    payload@1.15.8

    from

    payload@2.0.4

    .



    Is there a specific reason why payload is set to

    latest

    instead of

    ^2.0.0

    ? It's very annoying to have npm downgrade payload without any notice because of other dependencies.

  • discord user avatar
    denolfe
    Payload Team
    last month

    Sounds like a peer dependency problem that npm doesn't handle as well as yarn. Likely plugin stripe needs to be upgraded to support 2.0 on npm projects.



    I will look into this today.



    āœ… Create-payload-app was updated. Payload and all other @payloadcms/ dependencies now are more explicit in their versioning



    Regarding this:


    It's very annoying to have npm downgrade payload without any notice because of other dependencies.

    This is why we default to yarn if yarn is present, it handles issues like this, whereas npm does not.



    The work to update plugin-stripe to 2.0 and handle peer dependencies with npm has been assigned šŸ‘

  • default discord avatar
    slippery_jim
    last month

    awesome thanks for the fix!

  • default discord avatar
    artemis_primo
    last month

    In the release announcement for 2.0, they mention pnpm. But just now you mentioned only npm and yarn. I’d like to use pnpm if possible. Could you clarify @denolfe ?

  • discord user avatar
    denolfe
    Payload Team
    last month

    pnpm is also supported when creating a project with --use-pnpm šŸ‘ I didn't mention it because a lot of people aren't familiar with that manager.



    The mention of pnpm in the blog post was unrelated and referred to our internal usage in our monorepo.

  • default discord avatar
    artemis_primo
    last month

    Thanks @elliot! But respectfully, I say, "Spread that Gospel my son!" šŸ™‚ pnpm rocks.

  • discord user avatar
    denolfe
    Payload Team
    last month

    I agree with you, there. I've moved from yarn to pnpm as well, and I don't ever plan on going back.

  • default discord avatar
    artemis_primo
    last month

    Btw, @denolfe , when you have a moment, can you have look at my recent question aobut "a front end dev guide"?

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.