You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried using require(), no luck. It still thinks it's a module:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/sander/github/tablelandnetwork/example-voter/node_modules/@tableland/local/bin/cjs/main.js from /Users/sander/github/tablelandnetwork/example-voter/test/integration/build/test/integration/ask.test.js not supported.
main.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/sander/github/tablelandnetwork/example-voter/node_modules/@tableland/local/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at Object.<anonymous> (/Users/sander/github/tablelandnetwork/example-voter/test/integration/build/test/integration/ask.test.js:11:15)
at importOrRequire (/Users/sander/github/tablelandnetwork/example-voter/node_modules/tape/bin/import-or-require.js:14:2)
at /Users/sander/github/tablelandnetwork/example-voter/node_modules/tape/bin/tape:88:8
at Array.reduce (<anonymous>)
at importFiles (/Users/sander/github/tablelandnetwork/example-voter/node_modules/tape/bin/tape:85:27) {
code: 'ERR_REQUIRE_ESM'
}
I've tried importing /bin/cjs/main.js directly but get this complaint that it's not exported:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin/cjs/main.js' is not defined by "exports" in /Users/sander/github/tablelandnetwork/example-voter/node_modules/@tableland/local/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
at packageExportsResolve (node:internal/modules/esm/resolve:729:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/sander/github/tablelandnetwork/example-voter/test/integration/build/test/integration/setupTest.js:9:19) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
I'm trying to use this repo in https://github.com/tablelandnetwork/example-voter. This project uses hardhat, which doesn't support ESM modules w/ Typescript yet. See NomicFoundation/hardhat#3043.
I've tried using
require()
, no luck. It still thinks it's a module:I've tried importing
/bin/cjs/main.js
directly but get this complaint that it's not exported:Might be easiest to just play with my branch: https://github.com/tablelandnetwork/example-voter/tree/sander/local-tableland !
The text was updated successfully, but these errors were encountered: