I have nestjs app that works fine in development mode, but when I deploy it to DigitalOcean I have an error:
[2025-08-19 00:04:35] │ sh: 1: nest: not found
When I change NODE_ENV in environment variables from production to development then it works, but I dont think it is the proper solution. Also, here (getting `sh: 1: exec: nest: not found` error deploying nestjs to google app engine) the user suggested to move @nestjs/cli from dev-dependencies to dependencies and that solved my problem even with NODE_ENV=production. Is that a proper workaround? These are my scripts:
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
BUT, I have other, much larger nestsjs app and here the problem is similar with the difference that from the very start application was correctly deploying with NODE_ENV=production and @nestjs/cli in dev-dependencies. Now I did a huge merge request and unfortunately I have sh: 1: nest: not found as well here :( Here:
- when I change NODE_ENV to development, then app build ssuccessfully
- when I move
@nestjs/clitodev-dependenciesthen I have the same errorCannot find namespace 'Express'
What is the proper solution? Are some of above practices not recommended?