Home > OS >  'npm ERR! could not determine executable to run' in OpenShift pod
'npm ERR! could not determine executable to run' in OpenShift pod

Time:12-14

I am trying to deploy an Angular app to OpenShift and below is a copy of my package.json

{
  "name": "app-admin",
  "version": "0.1.0",
  "scripts": {
    "global": "npm install",
    "start": "npx ng serve",
    "build": "npx ng build",
    "watch": "npx ng build --watch --configuration development",
    "test": "npx ng test",
    "e2e": "npx ng e2e",
    "cypress:open": "cypress open",
    "cypress:run": "cypress run"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.2.0",
    "@angular/common": "^14.2.0",
    "@angular/compiler": "^14.2.0",
    "@angular/core": "^14.2.0",
    "@angular/forms": "^14.2.0",
    "@angular/platform-browser": "^14.2.0",
    "@angular/platform-browser-dynamic": "^14.2.0",
    "@angular/router": "^14.2.0",
    "drag-on-drop": "^3.6.1",
    "npm": "^9.2.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.6",
    "@angular/cli": "~14.2.6",
    "@angular/compiler-cli": "^14.2.0",
    "@cypress/schematic": "^2.2.0",
    "@types/jasmine": "~4.0.0",
    "axe-core": "^4.4.3",
    "cypress": "^10.10.0",
    "cypress-axe": "^1.0.0",
    "jasmine-core": "~4.3.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.7.2"
  },
  "overrides": {  
    "loader-utils@>2.0.0 <3": "2.0.4",
    "loader-utils@>3.0.0 <4": "3.2.1"
  }
}

The pods failed at npx ng serve with the following error

ERROR: ld.so: object 'libnss_wrapper.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object 'libnss_wrapper.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object 'libnss_wrapper.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
npm info using [email protected]
npm info using [email protected]
npm http fetch GET 200 https://registry.npmjs.org/npm 828ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/npm 881ms (cache miss)
npm http fetch GET 200 https://registry.npmjs.org/ng 1096ms (cache miss)
npm ERR! could not determine executable to run

I have tried every answer in this link and read this reddit thread. The solutions from the other stackoverflow post worked in the debug pod but when I add the step in the scripts. The pods failed with the same error in the next build again.

Things I have tried adding to the scripts:

"install": "npm install -g [email protected]"
"prestart": "npm install -g"

Also tried put npm version in the dependencies and specified the npm version using engines. None worked for me.

Any help is appreciated.

CodePudding user response:

You probably miss the glibc or nss_wrapper-libs package into your container. Some npm module require it to perform compilation during install (like couchbase module).

You could try to use a multi-stage build dockerfile an have glibc only in the builder image, not the final one.

CodePudding user response:

In my case, the issue occurred because the devdependencies in the package.json was not installed. I have to pass an environment variable NODE_DEV=development for them to be installed which solved my issue. Thanks to this post.

For future readers who encounter the same issue: If my solution does not work for you, please check if the other answers help with your situations.

  • Related