"tsc not found" during build

This was actually solved in another thread, but I’m trying to figure out why – and how to solve it a different way.

I get a build error on my Typescript Node/Express server that says “tsc not found.” I have typescript as a dev dependency and yarn install; yarn build as my build step: This is my package.json:

  "scripts": {
    "build": "tsc",
    "start": "node ./dist/src/index.js & node ./dist/src/utilities/cron.js",
    "dev": "nodemon ./src/index.ts & nodemon ./src/utilities/cron.ts",
    "test": "echo \"Error: no test specified\" && exit 1",
    "db:migrate": "knex migrate:latest"
  },
  "devDependencies": {
    "@types/cors": "^2.8.12",
    "@types/express": "^4.17.14",
    "@types/knex": "^0.16.1",
    "@types/node": "^18.7.20",
    "@types/node-cron": "^3.0.4",
    "@types/passport": "^1.0.11",
    "@types/passport-http-bearer": "^1.0.37",
    "@types/pg": "^8.6.5",
    "@typescript-eslint/eslint-plugin": "^5.38.1",
    "@typescript-eslint/parser": "^5.38.1",
    "eslint": "^8.24.0",
    "nodemon": "^2.0.20",
    "prettier": "^2.7.1",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.4"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "cors": "^2.8.5",
    "dotenv": "^16.0.3",
    "express": "^4.18.1",
    "knex": "^2.3.0",
    "node-cron": "^3.0.2",
    "openai": "^3.0.0",
    "passport": "^0.6.0",
    "passport-http-bearer": "^1.0.1",
    "pg": "^8.8.0",
    "twitter-api-v2": "^1.12.8"
  }

Here’s where it gets weird. If I change my NODE_ENV env variable to “development” instead of “production,” it solves the issue. This is a bandaid fix for me though because I don’t want my prod server to think it’s in dev (I used NODE_ENV elsewhere in my app). Anyone find a different workaround?

1 Like

Hi Jim,

Can you try omitting the NODE_ENV environment variable? We will automatically set this to production at runtime https://render.com/docs/environment-variables#node

1 Like

This worked but the build is using develop again

The issue was in my Knex JS config. Letting the default “NODE_ENV” run in prod worked and solved this issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.