CetusProtocol / cetus-clmm-sui-sdk

The clmm sdk on Sui.
Apache License 2.0
35 stars 25 forks source link

The import of the SDK fails. #2

Closed mouhusan closed 4 months ago

mouhusan commented 1 year ago

Version

You are using the following versions:

npm --versions
{
  npm: '9.6.3',
  node: '19.9.0',
}

package.json

The following dependencies are set:

"dependencies": {
    "@cetusprotocol/cetus-sui-clmm-sdk": "^2.6.13",
    "typescript": "^5.0.4"
  }

Error 1

The following error occurs:

Could not find a declaration file for module '@cetusprotocol/cetus-sui-clmm-sdk'. '/home/ubuntu/repo/sui_practice/src/node/cetis/node_modules/@cetusprotocol/cetus-sui-clmm-sdk/dist/index.js' implicitly has an 'any' type.

Solution

You can resolve the error by following these steps:

  1. Create a file named src/types/cetus-sui-clmm-sdk.d.ts.
  2. Add the following content to the file:

    declare module '@cetusprotocol/cetus-sui-clmm-sdk';

Error 2

The following runtime error occurs:

Uncaught SyntaxError SyntaxError: Unexpected token ;

TypeScript code

console.log('start main');
import { SDK } from '@cetusprotocol/cetus-sui-clmm-sdk';
console.log('imported');
const sdk = new SDK(netConfig.testnet);
console.log('ok');

Error Details

/usr/bin/node ./src/main.js
start main
main.ts:1
Process exited with code 1
Uncaught SyntaxError SyntaxError: Unexpected token ;
    at Module._compile (<node_internals>/internal/modules/cjs/loader.js:723:23)

JavaScript code

console.log('start main');
const cetus_sui_clmm_sdk_1 = require('@cetusprotocol/cetus-sui-clmm-sdk');
console.log('sdk loaded');

Error Details

/usr/bin/node ./src/main.js
start main
main.js:1
Process exited with code 1
Uncaught SyntaxError SyntaxError: Unexpected token ;
at Module._compile (<node_internals>/internal/modules/cjs/loader.js:723:23)

Unfortunately, a solution for Error 2 could not be found.