Files
redefined-designs/backend/package.json
T
bermudalamb 7d45b69305 build(uploads): add sharp for image re-encoding (#226)
Verified where it actually has to run rather than only here: the production image builds and `require('sharp')` succeeds inside it on Node v20.20.2, linux/x64, with libvips 8.18.6 and `withExif` available, needing no build toolchain. The architecture question is already settled by this same node:20-bookworm-slim base running in production today, and sharp ships glibc prebuilds for both linux-x64 and linux-arm64, so it adds no constraint that deployment did not already satisfy.

Installing it locally found a trap worth recording. sharp requires Node >=20.9.0 and its platform binary is an *optional* dependency, so npm skips it when the engine check fails and still reports success. Installed under this machine's default 18.16.1 the result is a node_modules that looks complete and throws `Could not load the "sharp" module using the win32-x64 runtime` at require time — which reads as a broken package rather than as a wrong Node version. The fix is `npm install --include=optional sharp` under Node 20+, and the prevention is using start-local.ps1 or run-tests.ps1, which switch first.

`engines` is now declared so npm at least warns, and the README's existing Node 20 section says what the failure looks like, since the error message names a runtime rather than a version and points nowhere useful.

The lockfile carries every platform variant including linux-x64 and linux-arm64, so a build on another platform resolves correctly. The Dockerfile does not copy the lockfile at all and installs fresh, so this matters for contributors rather than for the image.

Ref #226
2026-08-29 10:45:01 -05:00

65 lines
2.2 KiB
JSON
Executable File

{
"name": "redefined-designs-backend",
"version": "1.0.0",
"private": true,
"main": "dist/server.js",
"engines": {
"node": ">=20.9.0"
},
"scripts": {
"build": "tsc",
"lint": "eslint src scripts",
"start": "node dist/server.js",
"dev": "tsx watch src/server.ts",
"test": "npm run test:unit",
"test:unit": "jest -c jest.unit.config.js",
"test:unit:json": "jest -c jest.unit.config.js --json --outputFile=unit-results.json",
"test:unit:cov": "jest -c jest.unit.config.js --coverage",
"test:integration": "jest -c jest.integration.config.js --runInBand",
"test:integration:json": "jest -c jest.integration.config.js --runInBand --json --outputFile=integration-results.json",
"test:integration:cov": "jest -c jest.integration.config.js --runInBand --coverage --forceExit",
"bench:hashing": "tsx scripts/bench-hash-latency.ts",
"db:test:up": "docker compose -f docker-compose.test.yml up -d",
"db:test:down": "docker compose -f docker-compose.test.yml down -v",
"migrate:up": "node migrate.js up",
"migrate:down": "node migrate.js down",
"migrate:create": "node-pg-migrate create --migration-file-language js"
},
"dependencies": {
"@types/markdown-it": "^14.2.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"express": "^4.19.2",
"express-rate-limit": "^8.6.2",
"markdown-it": "^15.0.0",
"multer": "^1.4.5-lts.1",
"node-cron": "^3.0.3",
"node-pg-migrate": "^7.6.1",
"nodemailer": "^6.9.14",
"pg": "^8.12.0",
"sharp": "^0.35.4"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
"@types/bcryptjs": "^2.4.6",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/multer": "^1.4.11",
"@types/node": "^20.14.15",
"@types/node-cron": "^3.0.11",
"@types/nodemailer": "^6.4.15",
"@types/pg": "^8.11.6",
"@types/supertest": "^6.0.2",
"eslint": "^9.39.5",
"eslint-plugin-sonarjs": "^4.2.0",
"globals": "^17.11.0",
"jest": "^29.7.0",
"supertest": "^7.0.0",
"ts-jest": "^29.2.4",
"tsx": "^4.16.5",
"typescript": "^5.5.4",
"typescript-eslint": "^8.67.0"
}
}