Unable to deploy this library on Netlify or next-serverless, cannot resolve 'fast-crc32c'
See original GitHub issueDescribe 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 thenext.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:
https://github.com/gladly-team/next-firebase-auth/issues/235
Also a Discussion opened with no response here:
https://github.com/gladly-team/next-firebase-auth/discussions/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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (6 by maintainers)
@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
@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.