uhop / node-re2

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.
Other
495 stars 53 forks source link

Error with Next.js 12 #117

Closed jca41 closed 2 years ago

jca41 commented 2 years ago

Hi! After upgrading to next.js 12 i now get the following error:

ERROR   Error: Cannot find module './build/Release/re2'
Require stack:
- /var/task/node_modules/re2/re2.js
- /var/task/node_modules/url-regex-safe/lib/index.js
- /var/task/node_modules/@metascraper/helpers/index.js
- /var/task/node_modules/metascraper/src/index.js
- /var/task/.next/server/pages/api/metadata.js

I'm originally using this package via metascraper

uhop commented 2 years ago

Do you use yarn? Did you try to remove node_modules and reinstall everything with npm i?

jca41 commented 2 years ago

I do use yarn, I'll try with npm and let you know!

jca41 commented 2 years ago

Moved to npm and added a package-lock to the project, issue still persists for both node 16 and 14.5.

The "problem" is that it works fine locally but breaks when deploying to vercel. Vercel is using node 14.x apparently.

uhop commented 2 years ago

re2 is a C++ module that should be compiled. Do you have a C++ compiler installed as per node-gyp requirements? If re2 fails to download a precompiled version it reverts to compiling sources. Could you check that it doesn't fail?

jca41 commented 2 years ago
07:20:07.675 | > node-gyp-build
-- | --
07:20:07.884 | > re2@1.16.0 install /vercel/path0/node_modules/re2
07:20:07.884 | > install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR \|\| npm run rebuild
07:20:07.992 | Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.br ...
07:20:08.264 | Writing to build/Release/re2.node ...
07:20:08.737 | Done.

I get this from the deployment logs. Probably the best step for now is to get a minimal reproduction and ask the Vercel/Next.js team.

uhop commented 2 years ago

Hmm. It looks like the module was found and downloaded. Then it runs a check to make sure that everything is working as expected. I don't see any errors. If it was downloaded but not working, it will compile the module. I don't see it was needed.

uhop commented 2 years ago

I hope that the lack of updates means that you sorted it out. Please reopen, if you still need my help.

jca41 commented 2 years ago

Hey! I kind of gave up on the issue and decided not to upgrade to next 12 for now. Thanks anyways!