Facing "cannot file module" error in OpenShift Serverless.

Solution Verified - Updated -

Issue

  • Getting cannot file module error with npm packages while trying to create and deploy a function in Serverless.
Error: Cannot find module '../'
Require stack:
- /opt/app-root/src/node_modules/.bin/faas-js-runtime
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/opt/app-root/src/node_modules/.bin/faas-js-runtime:4:29)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/app-root/src/node_modules/.bin/faas-js-runtime' ]
}
npm timing command:run Completed in 202ms
npm timing npm Completed in 289ms
Error: timeout: service 'test-function' not ready after 120 seconds

Environment

  • Red Hat OpenShift Container Platform 4.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content