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

ENOENT: no such file or directory. v2 deployment #274

Closed
JohnatanNorman opened this issue Feb 21, 2019 · 7 comments

Comments

@JohnatanNorman
Copy link

@JohnatanNorman JohnatanNorman commented Feb 21, 2019

Hi there!
I was using @google-cloud/storage and I made json auth file file statically build so it would appear after build step.
image
As expected it appears in output but I still get this message that file doesn't exist.
image
I found the thread on the forums that you can build this google cloud file from now secrets with base64 encryption, but I don't have a problem with github that the guy had, and I don't like that workaround. Is there other option to make this file visible (will it work if I use it from /tmp?) or I have to implement solution with now secrets?
Thanks in advance!

@timothyis

This comment has been minimized.

Copy link
Member

@timothyis timothyis commented Feb 21, 2019

Hi @JohnatanNorman! Is this relating to one of our examples? I'm not sure how your project is laid out. Perhaps you could contact support@zeit.co for our support team to look into your issue if it is not related to an example.

@lucasavila00

This comment has been minimized.

Copy link

@lucasavila00 lucasavila00 commented Feb 21, 2019

When importing the auth.json file you have to use __dirname and resolve the path from this location to let NCC know that you're using this external file.

I'm doing it like this:

const FIREBASE_SERVICE_ACCOUNT = require(__dirname + "/serviceAccountKey.json");
@JohnatanNorman

This comment has been minimized.

Copy link
Author

@JohnatanNorman JohnatanNorman commented Feb 21, 2019

@degroote22 I am not sure I understand where I will put this. I was creating the storage like this

const storage = new Storage({ projectId, keyFile: 'cloud.json' })

Is there a better way to do this? Where do I put this file that you required?

@timothyis I am sorry for this, it's not about one of your examples, so I will close the issue. Thanks for the help link!

@lucasavila00

This comment has been minimized.

Copy link

@lucasavila00 lucasavila00 commented Feb 21, 2019

It's the same idea. That's how I'm doing it.

const storage = new Storage({
  projectId: "xxxxx",
  keyFilename: __dirname + "/serviceAccountKey.json",
});
@lucasavila00

This comment has been minimized.

Copy link

@lucasavila00 lucasavila00 commented Feb 21, 2019

@timothyis This issue with NCC and __dirname is a very common one.
I spent a couple of hours to solve it and that's why I'm answering these questions when I see one.
Consider explaining it better and documenting it. I don't even remember and can't find where I saw this tip.

There are a lot of people importing .json and .graphql files and these always cause this problem.

@timothyis

This comment has been minimized.

Copy link
Member

@timothyis timothyis commented Feb 21, 2019

I appreciate the help @degroote22! I'll pass this on to the ncc team.

@lucasavila00

This comment has been minimized.

Copy link

@lucasavila00 lucasavila00 commented Feb 21, 2019

I appreciate the help @degroote22! I'll pass this on to the ncc team.

Also recommend people to try and compile/run their code locally with ncc and explain that the builders use ncc because I don't remember where I saw it aswell.
I also spent some hours debugging ncc issues by deploying code to now while running locally with ts-node.
When I understood that the builders were using ncc I started to test my code locally with ncc and could fix issues waaay faster.

Thanks for your awesome work on now, ncc, etc.
I love it ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.