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
1 Answer 1
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).
9 Comments
Our app is running on port ${ PORT }); });PORT, e.g., app.listen(PORT, '0.0.0.0', () => { console.log( ... ?tsc in -watch mode is typically used only during development (i.e., only compiled JS is uploaded to or used in production). If not, then your start script should look like "start": "node server.js" because build already generated your JS.
{}button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code.