Error: cannot find package in yarn PnP
I’m working on a Yarn v3 workspace using Plug’n’Play (PnP) for package management, and I’m encountering a module resolution issue when running my server
When I try to start my development server using nodemon, I get the following error:
node:internal/modules/run_main:122
triggerUncaughtException(
^
Error: Cannot find package 'http-graceful-shutdown' imported from /home/raphico/repos/personal/projects/product-feedback-app/packages/server/src/index.ts
This happens even though http-graceful-shutdown is correctly listed in my dependencies in package.json.
Project Setup:
I have a monorepo using Yarn v3 with the following structure:
https://github.com/Raphico/product-feedback-app
server/package.json
{
"name": "@product-feedback-app/server",
"packageManager": "[email protected]",
"description": "Product feedback app backend",
"type": "module",
"scripts": {
"build": "yarn tsc",
"dev": "nodemon src/index.ts",
"start": "node dist/index.js",
"typecheck": "yarn tsc --noEmit",
"lint": "yarn eslint src"
},
"dependencies": {
"@fastify/compress": "^8.0.1",
"@fastify/cors": "^11.0.0",
"@fastify/helmet": "^13.0.1",
"@fastify/rate-limit": "^10.2.2",
"bytes": "^3.1.2",
"fastify": "^5.2.1",
"http-graceful-shutdown": "^3.1.14",
"parse-duration": "^2.1.3",
"pino": "^9.6.0",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/node": "^22.13.8",
"nodemon": "^3.1.9",
"ts-node": "^10.9.2",
"typescript": "^5.8.2"
}
}
nodemon.json
{
"watch": ["src"],
"ext": "ts",
"execMap": {
"ts": "node --loader ts-node/esm"
}
}
GitHub
GitHub - Raphico/product-feedback-app: a solution to the front-end ...
a solution to the front-end mentor product feedback app - Raphico/product-feedback-app
3 Replies
I don't have a more helpful suggestion other then give pnpm a shot. Yarn 2 plus was canned by most of the community
Damn, I will wait a couple of days for a solution on other platforms before migrating. Thank you for the feedback, tho
Yeah to be clear Theo and most of this server is pnpm pilled, so be aware of the opinions, but I've not seen a serious project attempt to use Yarn Berry at all. I did get your project working with pnpm on the side so it should be a lot easier