Home > other >  tsc: not found at heroku when I upload the React next js and node project
tsc: not found at heroku when I upload the React next js and node project

Time:05-14

I have react next and node js project and I want to deploy that project at heroku. That is the structure of my project:- enter image description here

and my package.json file is enter image description here if I add "Start": "next start" only the frontend works and if I changed it "Start": "tsc -p server/tsconfig.json -watch && node server.js" it's gave me the error.

error is :-enter image description here

CodePudding user response:

After Heroku installs the dependencies and devDependencies listed in package.json, all devDependencies get removed before the npm start command is run. So if you installed typescript under devDependencies and your project needs it at runtime, it won't be found. To stop it from being pruned, move typescript over to dependencies instead.

Another option would be to skip the pruning process altogether by setting the following config vars:

$ heroku config:set NPM_CONFIG_PRODUCTION=false YARN_PRODUCTION=false

Or set the NODE_ENV environment variable to anything other than production (Heroku's default).

  • Related