pnpm / pnpm

Fast, disk space efficient package manager
https://pnpm.io
MIT License
29.73k stars 1.01k forks source link

ts-node executable is not properly linked or resolved when using pnpx to run a prisma seed script in a NextJS Project #6464

Open SkyHustle opened 1 year ago

SkyHustle commented 1 year ago

pnpm version: 8.3.1

Code to reproduce the issue:

package.json
{
    "name": "ai-blog",
    "version": "0.1.0",
    "private": true,
    "prisma": {
        "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
    },
    "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
    },
    "dependencies": {
        "@headlessui/react": "^1.7.14",
        "@heroicons/react": "^2.0.17",
        "@prisma/client": "4.13.0",
        "@types/react": "18.0.38",
        "@types/react-dom": "18.0.11",
        "eslint": "8.39.0",
        "eslint-config-next": "13.3.1",
        "next": "13.3.1",
        "react": "18.2.0",
        "react-dom": "18.2.0"
    },
    "devDependencies": {
        "@tailwindcss/typography": "^0.5.9",
        "@types/node": "18.15.13",
        "autoprefixer": "10.4.14",
        "postcss": "8.4.23",
        "prisma": "^4.13.0",
        "tailwindcss": "3.3.1",
        "ts-node": "^10.9.1",
        "typescript": "5.0.4"
    }
}

Expected behavior:

When using npx and running npx prisma db seed everything works as expected

Environment variables loaded from .env
Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...
Start seeding ...
Seeding finished.

🌱  The seed command has been executed.

Actual behavior:

When using pnpx and running pnpx prisma db seed this is the output

.../Library/pnpm/store/v3/tmp/dlx-64057  |   +2 +
.../Library/pnpm/store/v3/tmp/dlx-64057  | Progress: resolved 2, reused 2, downloaded 0, added 2, done
Environment variables loaded from .env
Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...

An error occurred while running the seed command:
Error: Command failed with ENOENT: ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts
spawn ts-node ENOENT
 ERROR  Command failed with exit code 1: prisma db seed

pnpm: Command failed with exit code 1: prisma db seed
    at makeError (/usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:24230:17)
    at handlePromise (/usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:24801:33)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (/usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:206754:7)
    at async /usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:216086:21
    at async main (/usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:216053:34)
    at async runPnpm (/usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:216308:5)
    at async /usr/local/Cellar/pnpm/8.3.1/libexec/dist/pnpm.cjs:216300:7

Additional information:

vojtechmares commented 1 year ago

I can confirm this bug is not fixed on 8.6.1 and 8.6.3.