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

NextJS ENOENT: no such file or directory Error when trying to create Client #36

Open
thanvinhbaohoang opened this issue May 16, 2024 · 7 comments

Comments

@thanvinhbaohoang
Copy link

Description

When I try to initialize a new Client object, I get a no such file or directory
image

Expected Behavior

I expect it to run just like the provided example (which used Express instead of NextJS)

Actual Behavior

image

@AaronAtDuo
Copy link
Contributor

This looks very similar to the issues that came up in #26.

@thanvinhbaohoang What version of the library are you using?

@thanvinhbaohoang
Copy link
Author

@AaronAtDuo I tried this with v2.0.3 after checking the linked issue and its still giving me the same problem :(

@Fiontan
Copy link

Fiontan commented Jul 31, 2024

I've received a reply from duo from a noreply email stating that there is " an open feature request submitted to our Product team so that it can be considered during our next prioritization phase. I will go ahead and add you as an interested contact for this FR...". I cannot find a way to see existing feature requests so they may not be public.

@Fiontan
Copy link

Fiontan commented Jul 31, 2024

Looks similar to #21 and #5

@Adam-Schlichtmann
Copy link

Adam-Schlichtmann commented Aug 29, 2024

I was running into this using version 2.0.3.
I ended up adding this to my docker file to "mock" the package.json

RUN echo "{ \"version\": \"2.0.3\" }" > package.json

Make sure that the path to your package.json is back one directory from wherever you code is that is creating the Client.

You could also solve this using patch-package to remove this line from the constants.ts file

fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' })

@jeffreyparker
Copy link
Contributor

I can still reproduce this (or a variation of this) using the latest main with this docker command docker run --rm -it -v .:/src -p 3000:3000 node:20 bash -c "cd /src && npm install && cd ./example && npm install && npm run start"

The issue appears to be coming from the build_for_example step. If I remove the preinstall command, the example runs fine.

@johneatmon
Copy link

The problem seems to be this line.

I ended up using pnpm to patch this by changing path.join(__dirname, '../package.json') to path.join(process.cwd(), '/package.json'). It wasn't working for me in an Express project either.

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

6 participants