Closed HernanPaez closed 7 months ago
This is also happening to me. In fact, attempting to import any of the 4 necessary dependencies causes errors; '@ucanto/principal/ed25519', '@ucanto/core/delegation', '@ipld/car', '@web3-storage/w3up-client' all cannot be imported/accessed.
I am attempting to import and access these dependencies in a Docker image with Typescript.
When I try to isolate "the" issue to a single dependency by only importing/accessing one dependency at a time, I get the following errors;
'@ucanto/principal/ed25519':
{ "errorType": "Error", "errorMessage": "Package subpath './ed25519' is not defined by \"exports\" in /var/task/node_modules/@ucanto/principal/package.json", "code": "ERR_PACKAGE_PATH_NOT_EXPORTED", "stack": [ "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ed25519' is not defined by \"exports\" in /var/task/node_modules/@ucanto/principal/package.json", " at new NodeError (node:internal/errors:405:5)", " at exportsNotFound (node:internal/modules/esm/resolve:367:10)", " at packageExportsResolve (node:internal/modules/esm/resolve:647:13)", " at resolveExports (node:internal/modules/cjs/loader:567:36)", " at Module._findPath (node:internal/modules/cjs/loader:636:31)", " at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)", " at Module._load (node:internal/modules/cjs/loader:922:27)", " at Module.require (node:internal/modules/cjs/loader:1143:19)", " at require (node:internal/modules/cjs/helpers:119:18)", " at Object.<anonymous> (/var/task/util/ipfs.js:32:29)" ] }
'@ucanto/core/delegation':
{ "errorType": "Error", "errorMessage": "Package subpath './delegation' is not defined by \"exports\" in /var/task/node_modules/@ucanto/core/package.json", "code": "ERR_PACKAGE_PATH_NOT_EXPORTED", "stack": [ "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './delegation' is not defined by \"exports\" in /var/task/node_modules/@ucanto/core/package.json", " at new NodeError (node:internal/errors:405:5)", " at exportsNotFound (node:internal/modules/esm/resolve:367:10)", " at packageExportsResolve (node:internal/modules/esm/resolve:647:13)", " at resolveExports (node:internal/modules/cjs/loader:567:36)", " at Module._findPath (node:internal/modules/cjs/loader:636:31)", " at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)", " at Module._load (node:internal/modules/cjs/loader:922:27)", " at Module.require (node:internal/modules/cjs/loader:1143:19)", " at require (node:internal/modules/cjs/helpers:119:18)", " at Object.<anonymous> (/var/task/util/ipfs.js:32:22)" ] }
'@ipld/car':
{ "errorType": "Error", "errorMessage": "No \"exports\" main defined in /var/task/node_modules/@ipld/car/package.json", "code": "ERR_PACKAGE_PATH_NOT_EXPORTED", "stack": [ "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No \"exports\" main defined in /var/task/node_modules/@ipld/car/package.json", " at new NodeError (node:internal/errors:405:5)", " at exportsNotFound (node:internal/modules/esm/resolve:367:10)", " at packageExportsResolve (node:internal/modules/esm/resolve:647:13)", " at resolveExports (node:internal/modules/cjs/loader:567:36)", " at Module._findPath (node:internal/modules/cjs/loader:636:31)", " at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27)", " at Module._load (node:internal/modules/cjs/loader:922:27)", " at Module.require (node:internal/modules/cjs/loader:1143:19)", " at require (node:internal/modules/cjs/helpers:119:18)", " at Object.<anonymous> (/var/task/util/ipfs.js:32:15)" ] }
'@web3-storage/w3up-client':
{ "errorType": "Error", "errorMessage": "require() of ES Module /var/task/node_modules/@web3-storage/w3up-client/dist/src/index.node.js from /var/task/util/ipfs.js not supported.\nInstead change the require of index.node.js in /var/task/util/ipfs.js to a dynamic import() which is available in all CommonJS modules.", "code": "ERR_REQUIRE_ESM", "stack": [ "Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/node_modules/@web3-storage/w3up-client/dist/src/index.node.js from /var/task/util/ipfs.js not supported.", "Instead change the require of index.node.js in /var/task/util/ipfs.js to a dynamic import() which is available in all CommonJS modules.", " at Object.<anonymous> (/var/task/util/ipfs.js:32:29)", " at Object.<anonymous> (/var/task/handlers/metadata.js:4:16)", " at Object.<anonymous> (/var/task/index.js:10:20)", " at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)", " at _tryRequire (file:///var/runtime/index.mjs:1052:25)", " at _loadUserApp (file:///var/runtime/index.mjs:1081:22)", " at UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:27)", " at start (file:///var/runtime/index.mjs:1282:42)", " at file:///var/runtime/index.mjs:1288:7" ] }
I'm experiencing the same problem. To provide additional context, my code is executed within a Docker environment, and I'm using Node.js version 16.20.2.
@HernanPaez which version of node are you using? The client requires version 18 or higher.
@thanapat-civicledger let us know if the issue persists after upgrading node.
@magror which version of node are you using?
@magror which version of node are you using?
@heyjay44 Im using Node 18
My Dockerfile uses Node 18, too: FROM public.ecr.aws/lambda/nodejs:18
Hey folks @HernanPaez @magror
Looks like this is a result of typescript project being compiled to CJS, which is not supported anymore by web3.storage. Like most of JS ecosystem we are moving towards ESM only module publishing.
I created a local typescript project where I made package.json
to have a "type": "module",
+ on your tsconfig.json
I updated the module to NodeNext
. Can you try it out?
@vasco-santos What is "CSM"? I cannot find any information about that acronym. Did you mean "CJS"?
Bahm, yes CJS 🤦🏼♂️
@vasco-santos adding type: module
to package.json and setting module: NodeNext
in tsconfig.json has allowed me to import/access this dependency. Thank you
Hi! I am trying to replace the old web3storage library with the new one but I am having problems when I try to run my server
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './ed25519' is not defined by "exports" in /Users//server-proyect/node_modules/@ucanto/principal/package.json
I don't know how to fix this issue. This is a new typescript project
Here is my code: