payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.73k stars 1.57k forks source link

Unable to start payload / Yarn build error #1244

Closed fizzterious closed 2 years ago

fizzterious commented 2 years ago

Bug Report

Current Behavior

Unable to start the app due to error thrown from the payload dependency on pino.

Error: pino tried to access pino-pretty, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

I'm running payload 1.1.10 with node 18.9.0 and yarn 3.2.3 (same error occurs on node 16 however)

Expected Behavior

App should start without errors (works fine in npm).

Possible Solution

There's a thread on the pino github page you can follow for more details, but I believe updating to the latest version of Pino may fix the error. The current latest version is 8.6.1 but payload is currently running ^6.4.1".

Steps to Reproduce

I didn't run into this error when using npm, so I believe it to be limited only to yarn/pnp, but repro steps are simple:

  1. Setup barebones payload app: $ npx create-payload-app
  2. cd to install directory: i.e. cd /my-app
  3. run yarn dev
  4. Error will throw soon after attempting to start the express server

Detailed Description

For additional context, I recently migrated a payload app from a small repo using npm to a monorepo using yarn, and after switching am unable to start payload.

I tried the same from a fresh install using npx create-payload-app but still see the error.

Here's the full error output:

Error: pino tried to access pino-pretty, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: pino-pretty
Required by: pino@npm:6.14.0 (via /Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/)

Require stack:
- /Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/tools.js
- /Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/levels.js
- /Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/proto.js
- /Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/pino.js
- /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/dist/utilities/logger.js
- /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/dist/graphql/errorHandler.js
- /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/dist/graphql/registerSchema.js
- /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/dist/init.js
- /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/dist/index.js
- /Volumes/Sites/cms-test/apps/cms.huckleduck.com/src/server.ts
    at Function.require$$0.Module._resolveFilename (/Volumes/Sites/cms-test/.pnp.cjs:31262:13)
    at Function.require$$0.Module._load (/Volumes/Sites/cms-test/.pnp.cjs:31116:42)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at getPrettyStream (/Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/tools.js:183:27)
    at normalizeArgs (/Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/lib/tools.js:352:16)
    at pino (/Volumes/Sites/cms-test/.yarn/cache/pino-npm-6.14.0-d486952bad-eb13e12e3a.zip/node_modules/pino/pino.js:79:28)
    at /Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/src/utilities/logger.ts:7:59
    at memoized (/Volumes/Sites/cms-test/.yarn/cache/micro-memoize-npm-4.0.11-1ff64ab5d7-7267b714bf.zip/node_modules/micro-memoize/src/index.ts:99:27)
    at Object.<anonymous> (/Volumes/Sites/cms-test/.yarn/cache/payload-npm-1.1.10-faf4ab3170-25e3c3b45f.zip/node_modules/payload/src/graphql/errorHandler.ts:4:25)
[nodemon] app crashed - waiting for file changes before starting...

Screenshot of error

Here's a screenshot of the error in a newly created application:

image

denolfe commented 2 years ago

Hey @fizzterious , I followed your replication steps verbatim with the same node and payload versions, but I did not have an issue starting up Payload.

Running yarn why for both pino and pino-pretty gave "pino@6.14.0" and "pino-pretty@4.8.0" - the same versions as you.

fizzterious commented 2 years ago

Thanks for testing that out @denolfe. For the record, I was able to get it to work with yarn 3 by disabling Plug'n'Play.

I would love to try get pino update to latest & see if pnp works since pino-pretty was deprecated. But, I'll go ahead and close this out since I did get it to work (I might try and find some time to raise a PR to update the version in the future though).

The solution, if anybody stumbles on this in the future (and you're okay disabling pnp), it's simple enough to get working with yarn 3. You just need to set nodeLinker to node-modules and it's able to resolve the linking and start payload just fine. You can see step 5 in the yarn v3 migration guide if you need more info.

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.