X2Y2-io / x2y2-sdk

X2Y2 Node.js SDK.
MIT License
26 stars 26 forks source link

Cannot find module '@x2y2-io/sdk/dist/network' #19

Closed daizong closed 1 year ago

daizong commented 1 year ago
  1. npm install @x2y2-io/sdk@0.3.0 --save
  2. ts-node test.ts Got the error: /usr/local/lib/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366 throw new ERR_MODULE_NOT_FOUND( ^ CustomError: Cannot find module '/Users/main/workspace/node/x2y2-api/node_modules/@x2y2-io/sdk/dist/network' imported from /Users/daizong/workspace/node/x2y2-api/src/test.ts at finalizeResolution (/usr/local/lib/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366:11) at moduleResolve (/usr/local/lib/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:801:10) at Object.defaultResolve (/usr/local/lib/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11) at /usr/local/lib/node_modules/ts-node/src/esm.ts:218:35 at entrypointFallback (/usr/local/lib/node_modules/ts-node/src/esm.ts:168:34) at /usr/local/lib/node_modules/ts-node/src/esm.ts:217:14 at addShortCircuitFlag (/usr/local/lib/node_modules/ts-node/src/esm.ts:409:21) at resolve (/usr/local/lib/node_modules/ts-node/src/esm.ts:197:12) at resolve (/usr/local/lib/node_modules/ts-node/src/child/child-loader.ts:15:39) at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)

code: test.ts `import {init} from '@x2y2-io/sdk' import { Network } from '@x2y2-io/sdk/dist/network'

export var test = async function() { init("xxxxx", Network.Mainnet) } await test()`

node version: v16.15.1 ts-node version: v10.8.1

jcmlumacad commented 1 year ago

how did you solve this?

daizong commented 1 year ago

how did you solve this?

I changed ts project to js project.

lamolivier commented 1 year ago

Hi,

I have the exact same issue, even when running with node test.js. Did you change anything to make the import work ?

node version: v16.19.1