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

Unable to deploy this library on Netlify or next-serverless, cannot resolve 'fast-crc32c' #236

Closed
uncvrd opened this issue Jul 25, 2021 · 7 comments
Labels
wontfix This will not be worked on

Comments

@uncvrd
Copy link
Contributor

uncvrd commented Jul 25, 2021

Describe the bug
Unfortunately, it appears that this library cannot be built when the next.config.js defines a target: serverless. An error occurs stating the following:

ModuleNotFoundError: Module not found: Error: Can't resolve 'fast-crc32c' in '/Users/jordan/GitHub/next-firebase-auth/example/node_modules/hash-stream-validation'

Both next-serverless and netlify require defining the target as serverless to be deployed using their libraries/services. Apparently target: serverless deploys an individual lambda for each page that needs it and I guess the firebase-admin package that relies on hash-stream-validation expects a nodejs environment to execute properly and cannot be bundled with webpack? I'm not an expert but that's sort of what I've picked up and I hope someone with more knowledge in this area can pick up from here.

Version
0.13.2

To Reproduce

  • Use the example directory found in this repo
  • Add target: serverless to the next.config.js
  • Run npm run build

Expected behavior
I expect to be able to build my project using target: serverless without errors so I can deploy on services such as Netlify or on next-serverless.

Additional context
I apologize as I do not have a solution for this issue, there was a ticket opened and promptly closed in this repo regarding the same problem with no resolution here:

#235

Also a Discussion opened with no response here:

#225

So I figured I'd open this and actively contribute to figuring out the problem with others here. Please let me know what I can do to help!


Edit: As an aside, I suppose it makes sense right? When I install firebase-admin to my next app, it detects it's not a server environment so dependencies such as fast-crc32c are not installed in my node_modules like they are for an express app. That's why I receive the Module not found error. The question now is, how do we prevent webpack from throwing an error when attempting to build the project since it detects that missing dependency?

A workaround is to just manually install the fast-crc32c package, however this does not work well when sharing projects to team members as they'll need to manually install the packages after a traditional npm install ...just a thought.

@kmjennison
Copy link
Contributor

I haven't looked at this closely yet, but it might be related to #207.

@kmjennison kmjennison added bug Something isn't working help wanted Extra attention is needed labels Aug 2, 2021
@Izhaki
Copy link
Contributor

Izhaki commented Aug 3, 2021

Importing Node Dependencies in Client Builds

This is the same issue as in this SO question and the answer within applies here. firebase-admin gets bundled into client side code.

The same issue happens on my fork mentioned in #207 - this has nothing to do with the distribution.

There's this: vercel/next.js#20487 (comment)

And also related: vercel/next.js#4940

@Izhaki
Copy link
Contributor

Izhaki commented Aug 3, 2021

@uncvrd I would actually recommend filing this issue on the NextJS Repo.

@kmjennison
Copy link
Contributor

Yes, it looks like target: serverless is discouraged now and even undocumented: vercel/next.js#20790

Unless that changes in Next.js, I don't think we'll support it here.

@kmjennison kmjennison added wontfix This will not be worked on and removed bug Something isn't working help wanted Extra attention is needed labels Aug 7, 2021
@uncvrd
Copy link
Contributor Author

uncvrd commented Aug 7, 2021

No problem, thanks for looking in to it

@IzioDev
Copy link

IzioDev commented Aug 16, 2021

@uncvrd I am using the serverless component : @sls-next/serverless-component@3.2.0.

And I ran into your issue. Did you found a solution in-order-to build the nextjs application into a serverless environment ?

Thanks.

@uncvrd
Copy link
Contributor Author

uncvrd commented Aug 16, 2021

@izio38 technically you can fork the project comment out any references to firebase-admin where it's imported (removing the local dependency of fb admin in your project too) and it'll build / deploy.

OR you can just manually install the node dependencies required. But highly do not recommend as collaboration will be a pain as theyll not auto install with 'npm i'.

But I just switched to Vercel instead and it works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants