Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loopback 4 deployment in heroku, lb-tsc not found error

I'm trying to deploy a loopback 4 app into heroku. But after publishing it npm-start command not working in heroku console. its throwing sh: 1: lb-tsc not found. package.json is as follows

"devDependencies": {
"@loopback/build": "^3.0.0",
"@loopback/eslint-config": "^5.0.0",
"@loopback/testlab": "^1.10.0",
"@types/node": "^10.17.6",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"eslint": "^6.7.2",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-eslint-plugin": "^2.1.0",
"eslint-plugin-mocha": "^6.2.2",
"source-map-support": "^0.5.16",
"typescript": "~3.7.3"},
"scripts": {
    "build": "lb-tsc",
    "build:watch": "lb-tsc --watch",
    "clean": "lb-clean dist *.tsbuildinfo",
     .......
    "lb-tsc": "lb-tsc",
    "postinstall": "npm run lb-tsc"
  }
like image 709
Pranav Ramachandran Avatar asked Jan 17 '26 08:01

Pranav Ramachandran


2 Answers

Creating a Procfile in the root of the project containing web: node . fixed this for me. Without it, Heroku will default to starting the app by calling npm run which tries to run the build process, and since @loopback/build is set up as a dev dependency by default, this results in the lb-tsc not found error.

like image 105
Tom Monks Avatar answered Jan 20 '26 03:01

Tom Monks


When heroku runs node application the value of process.env.NODE_ENV is "production" you may check it from heroku terminal bash by typing node and then process.env And this means that dev dependencies are not resolved.

Below steps work fine to me

  1. Open package.json file copy all from dev dependeny section and paste it to dependency section in package.json
  2. git add . then git commit and then git push heroku master

Another Solution: After pushing files to heroku using git push heroku master go to heroku terminal from https://dashboard.heroku.com/ and start console and then run command node dist/index.js so this command will start loopBack application make sure dist folder is available.

like image 23
Neeraj Negi Avatar answered Jan 20 '26 05:01

Neeraj Negi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!