next.js: `next build` fails with "Module did not self-register."
Bug report
Describe the bug
next build fails with following error after upgrade to Next 9.
{ Error: Module did not self-register.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/home/vista1nik/Documents/nextjs-project/node_modules/grpc/src/grpc_extension.js:32:13)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12) type: 'Error', '$error': '$error' }
Error happens after compilation. Last Build trigger before error is: https://github.com/zeit/next.js/blob/5a54e8715a7a7a92175addc19f4ec9f8f7bbd2e7/packages/next/build/index.ts#L342
To Reproduce
https://github.com/jpbow/module-register-build-issue
Expected behavior
next build success
System information
- OS: Arch Linux
- Version of Next.js: 9.0.0
Additional context
Tried yarn install --forceand Clean depends install.
next . dev-command work properly.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 22
- Comments: 56 (14 by maintainers)
Commits related to this issue
- Only enable worker threads if there is more than 1 worker Multiple worker threads can cause problems when certain dependencies are being used, see e.g. https://github.com/zeit/next.js/issues/7894 Th... — committed to ctavan/next.js by ctavan 7 years ago
- Only enable worker threads if there is more than 1 worker Multiple worker threads can cause problems when certain dependencies are being used, see e.g. https://github.com/zeit/next.js/issues/7894 Th... — committed to ctavan/next.js by ctavan 7 years ago
- Only enable worker threads if there is more than 1 worker Multiple worker threads can cause problems when certain dependencies are being used, see e.g. https://github.com/zeit/next.js/issues/7894 Th... — committed to ctavan/next.js by ctavan 7 years ago
- Add integration test to cover #7894 — committed to ctavan/next.js by ctavan 7 years ago
- Disable worker_threads by default for firebase compatibility (#9199) * Pass config.experimental.cpus to export during build Currently, there is no way of specifying the number of worker threads of `... — committed to vercel/next.js by ctavan 7 years ago
- configパッケージを追加、NODE_ENV=productionでgrpcパッケージに依存しているプロジェクトをビルドできない問題があったのでnextjsをバージョンアップ(9.1.2) https://github.com/zeit/next.js/issues/7894 — committed to takayuki-ochiai/basecamp by takayuki-ochiai 7 years ago
- feat: add next plugin that deals with webpack workarounds The canvas package, which is a dependency of jsdom, has a native binding which causes the following error during Next.js build process: "Modu... — committed to moxystudio/next-intl by satazor 7 years ago
- feat: add next plugin that deals with webpack workarounds The canvas package, which is a dependency of jsdom, has a native binding which causes the following error during Next.js build process: "Modu... — committed to moxystudio/next-intl by satazor 7 years ago
- feat: add next plugin that deals with webpack workarounds The canvas package, which is a dependency of jsdom, has a native binding which causes the following error during Next.js build process: "Modu... — committed to moxystudio/next-intl by satazor 7 years ago
- feat: add next plugin that deals with webpack workarounds (#4) The canvas package, which is a dependency of jsdom, has a native binding which causes the following error during Next.js build process: ... — committed to moxystudio/next-intl by satazor 7 years ago
HEY EVERYBODY! Just Add
“engines”: { “node”: “10.x” }
To your package.json
You are welcome coders.
I have a feeling that it’s caused by newly added build report. Because the error throws after build completes
This change has been released as
next@9.0.4. You may upgrade your application(s)!tested and #8290 fixes it. When is the canary release coming that contains it?
@timneutkens @Vista1nik I’ve created a reproduction here https://github.com/jpbow/module-register-build-issue
I’m having same issue.
But when I comment out ‘import firebase/firestore’, this issue did’nt happen.
But I need firebase/firestore. this is not solution.
With 9.1.1 and firestore still have this issue.
EDIT: downgrading to 9.0.5
Hi @getorca, the fix should be in
v9.0.4-canary.3which is up nowseems like this regressed in
9.0.6. downgrading to9.0.5or9.0.4still builds properly. with9.0.6i get the same error aboutgrpcI am having the same issue using firebase… Has anyone found a deployment workaround?
@jpbow Thanks for repoduction, added to issue.
As I understand any dependency with grpc breaking nextjs build?
I have now proposed https://github.com/zeit/next.js/pull/9199 where setting
config.experimental.cpus: 1will disable worker threads altogether. This makesnext buildsucceed for all use cases that involvegrpcand that I have tested.For me, that would be an acceptable workaround until the issue is fixed in
grpcorfirebase. There is already an issue in thegrpcrepo (https://github.com/grpc/grpc-node/issues/778) but apparently the solution depends on upstream changes in node (https://github.com/nodejs/nan/issues/844).I now believe that this is something that rather needs to be fixed in
grpc, not here. At least I don’t see a straightforward way of fixing it in Next.js without going back to older parallelization technology which would definitely hurt the codebase.If https://github.com/zeit/next.js/pull/9199 gets accepted we would at least have a way to build projects that depend on
firebase/firestore, even though build times might be longer since we cannot make use of parallelism.It’s clear @ctavan ! Thanks a lot for this explanation. Unfortunately I still have the issue with experimental: { cpus: 1, }
`Warning: You have enabled experimental feature(s). Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
Compiled successfully.
Automatically optimizing pages … Error occurred prerendering /download/[document_id]: Error: Failed to load /Users/me/myproject/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node. Module did not self-register.
etc…`
I switch form Node 11.9.0 to Node 10.12 and Node 13.0.1 to Node 12.13.0 without success…
For some reason building my project on mac OS works, while on Debian I get the same “Module did not self-register” error.
It’s seems like NextJS 9 is incompatible with dependencies which use GRPC in anyway. Currently I trying to find any other package which use GRPC to confirm that.
just chiming in, this also fails when deploying with now 2.0