rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

Module not found: Can't resolve 'rdf-canonize-native' during build in RDFLib dependency

Open danielbakas opened this issue 10 months ago • 4 comments

Hi!

While building a Next.js project that includes RDFLib ([email protected]), the build fails due to a missing module error in rdf-canonize:

Module not found: Can't resolve 'rdf-canonize-native' in '.../node_modules/.pnpm/[email protected]/node_modules/rdf-canonize/lib'

This error seems to originate from rdf-canonize, which is a dependency of jsonld, which in turn is required by RDFLib.

Steps to Reproduce

  1. Create a Next.js project ([email protected]).
  2. Install [email protected] using pnpm.
  3. Run next build.

Expected Behavior

The build should complete successfully without missing dependencies.

Actual Behavior

  • The build fails with Module not found: Can't resolve 'rdf-canonize-native'.
  • The issue appears in the dependency chain: rdflib → jsonld → rdf-canonize.
  • A separate TypeError: Cannot set properties of undefined (setting 'WordArray') also appears in the logs.

Environment

  • Package Manager: pnpm
  • RDFLib Version: 2.2.37
  • Next.js Version: 15.2.1
  • Node.js Version: 23.9.0

Attempts to solve

  • Add rdf-canonize-native dependency → Failed (different error) at installation

Full Log

next dev

   ▲ Next.js 15.2.1
   - Local:        http://localhost:3000
   - Network:      http://192.168.68.105:3000

 ✓ Starting...
 ✓ Ready in 2.7s
 ○ Compiling / ...
 ⚠ ./node_modules/.pnpm/[email protected]/node_modules/rdf-canonize/lib/index.js
Module not found: Can't resolve 'rdf-canonize-native' in '.../node_modules/.pnpm/[email protected]/node_modules/rdf-canonize/lib'

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/rdf-canonize/lib/index.js
./node_modules/.pnpm/[email protected]/node_modules/rdf-canonize/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/jsonld/lib/jsonld.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/jsonld/lib/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rdflib/esm/jsonldparser.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rdflib/esm/fetcher.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rdflib/esm/index.js

Conclusion

Thank you in advance!!!

danielbakas avatar Mar 06 '25 03:03 danielbakas

Related to https://github.com/digitalbazaar/rdf-canonize-native/issues/10

danielbakas avatar Mar 06 '25 03:03 danielbakas

https://github.com/digitalbazaar/jsonld.js/issues/567#issuecomment-2707527873

davidlehn avatar Mar 07 '25 21:03 davidlehn

Can I do anything to help resolve this issue. Is it a new version issue ?

bourgeoa avatar Mar 08 '25 15:03 bourgeoa

I don't understand the potential implications, but reading the notes above and https://github.com/digitalbazaar/jsonld.js/issues/567, this works for me using webpack v5.92.

  resolve: {
    fallback: {
      "rdf-canonize-native": false
    }      
  }

I received the error since at least rdflib v2.2.12 and is still occurring in v2.2.35.

Thank you @danielbakas asking and following up with rdflib and jsonld.

tonybranfort avatar Apr 09 '25 17:04 tonybranfort