Skip to content

Run fails when project contains node_modules directory. #333

@matejvasek

Description

@matejvasek

When trying to build & running an image from a project containing the node_modules directory I got following error:

s2i build ./ registry.access.redhat.com/ubi8/nodejs-16 quay.io/mvasek/fn-n:latest

node:internal/modules/cjs/loader:936load Completed in 38ms
  throw err;
  ^

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:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/opt/app-root/src/node_modules/.bin/faas-js-runtime:4:29)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/app-root/src/node_modules/.bin/faas-js-runtime' ]
}

With NodeJS 14 I got different error:

s2i build ./ registry.access.redhat.com/ubi8/nodejs-14 quay.io/mvasek/fn-n:latest

---> Installing application source ...
---> Installing all dependencies
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 298 packages in 1.739s

59 packages are looking for funding
run `npm fund` for details

found 7 vulnerabilities (4 high, 3 critical)
run `npm audit fix` to fix them, or `npm audit` for details
---> Building in production mode
---> Pruning the development dependencies
npm ERR! code EEXIST
npm ERR! path /opt/app-root/src/node_modules/.bin/tape
npm ERR! Refusing to delete /opt/app-root/src/node_modules/.bin/tape: is outside /opt/app-root/src/node_modules/tape and not a link
npm ERR! File exists: /opt/app-root/src/node_modules/.bin/tape
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/app-root/src/.npm/_logs/2022-05-14T15_46_23_798Z-debug.log
Build failed
ERROR: An error occurred: non-zero (13) exit code from registry.access.redhat.com/ubi8/nodejs-14

I had to either delete the node_modules or put it into s2i ignore list.

Is this expected behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions