aki
aki

Reputation: 323

sh: ng: command not found Failed to exec start script on openshift while deploying

I hit the below error on container when i deploy the app on Open shift.

status of container is Crash Loop Back-off

Local env works fine with no errors.

I made sure angular package versions are aligned to get the build successful.

> ng serve

sh: ng: command not found
npm info lifecycle [email protected]~start: Failed to exec start script
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `ng serve`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm timing npm Completed in 122ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/app-root/src/.npm/_logs/2020-04-10T15_14_11_050Z-debug.log

My package.json looks like below

  "name": "dashboard",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14",
    "@angular/material": "7.3.2",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@swimlane/ngx-charts": "^13.0.2",
    "chart.js": "^2.9.3",
    "ng2-charts": "^2.3.0",
    "rxjs": "~6.4.0",
    "sessionstorage": "^0.1.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.26",
    "@angular/cli": "^8.3.26",
    "@angular/compiler-cli": "~8.2.13",
    "@angular/language-service": "~8.2.13",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^8.10.59",
    "codelyzer": "^5.2.1",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "^5.4.3",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
  }
}

Any thoughts or help is appreciated.

Upvotes: 0

Views: 2264

Answers (1)

Chandan S
Chandan S

Reputation: 173

Just add npx before ng serve like this npx ng serve

If you have installed the dependencies locally and need to refer those packages instead of global. use npx before the the command eg: npx ng serve refers to the locally installed package. ng serve refers to the global package.

npm version 5.2+

Upvotes: 1

Related Questions