Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Encoungering an unexpected ENOTDIR while trying to open non-existing runtime.json #763

Open
mvhenten opened this issue Apr 24, 2024 · 0 comments

Comments

@mvhenten
Copy link

mvhenten commented Apr 24, 2024

Describe the bug

I'm running an npm build inside npm workspace on AWS codebuild resulting in a rather unexpected ENOTDIR:

npm ERR! path /codebuild/output/src3165309868/src/packages/client
npm ERR! command failed
npm ERR! command sh -c npm run prepare:virtual-config && npm run build
npm ERR! > @dittoapp/client@0.0.0 prepare:virtual-config
npm ERR! > ./plugins/generate-types.mjs > plugins/virtual-config.d.ts
npm ERR! /codebuild/output/src3165309868/src/node_modules/config/lib/config.js:832
npm ERR!       throw new Error('Config file ' + fullFilename + ' cannot be read. Error code is: '+e2.code
npm ERR!             ^
npm ERR! 
npm ERR! Error: Config file /codebuild/output/src3165309868/src/packages/client/config/runtime.json cannot be read. Error code is: ENOTDIR. Error message is: ENOTDIR: not a directory, open '/codebuild/output/src3165309868/src/packages/client/config/runtime.json'
npm ERR!     at util.parseFile (/codebuild/output/src3165309868/src/node_modules/config/lib/config.js:832:13)
npm ERR!     at util.loadFileConfigs (/codebuild/output/src3165309868/src/node_modules/config/lib/config.js:707:28)
npm ERR!     at new Config (/codebuild/output/src3165309868/src/node_modules/config/lib/config.js:116:27)
npm ERR!     at Object.<anonymous> (/codebuild/output/src3165309868/src/node_modules/config/lib/config.js:1515:33)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1356:14)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1197:32)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:1013:12)
npm ERR!     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:202:29)
npm ERR!     at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
npm ERR! 
npm ERR! Node.js v18.19.1

The repo is organized with each package symlinking the config folder in root:

config/
   runtime.json
packages/
   client/
      config --> ../../config

This works just fine on local development and inside a github action, but CodeBuild chokes. After some tinkering, setting NODE_CONFIG_DIR=../../config fixed the build so it's clearly an issue with the symlink approach - looking trough the code I am mystified by the ENOTDIR thrown by the readFileSync on config.js:832...

Please tell us about your environment:

  • node-config version: ^3.3.11
  • node-version: v20.11.1
  • NODE_ENV=development (explicitly set in buildspec)
  • I do not have a runtime.json anywhere in my project

Other information

I am aware this is a problem in my setup (AWS CodeBuild!), not a problem in node-config, but posting this in the hope someone has seen this and knows why the symlink is broken on this particular environment (CodeBuild on some flavour of Amazon Linux).

Please feel free to close this if you're as mystified as I am :)

@mvhenten mvhenten changed the title [BUG] Here's precisely how it doesn't work. [BUG] Encoungering an unexpected ENOTDIR while trying to open non-existing runtime.json Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant