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
When loading the SDK with require('@hashgraph/sdk'), I get a bunch of errors like
node_modules/@hashgraph/sdk/lib/Transfer.d.ts:75:20 - error TS1340: Module 'long' does not refer to a type, but is used as a type here. Did you mean 'typeof import('long')'?
75 export type Long = import("long");
~~~~~~~~~~~~~~
node_modules/long/umd/index.d.ts:1:18 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead.
1 import Long from "../index.js";
and the error
scripts/create-token.js:21:9 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@hashgraph/sdk")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to 'package.json'.
21 require('@hashgraph/sdk');
~~~~~~~~~~~~~~~~
Steps to reproduce
In a new npm JavaScript project, add the SDK 2.55.1 and typescript. The package.json's type is left untouched (it's using commonjs as default.
Then create a minimal script that requires @hashgraph/sdk, for example
require('@hashgraph/sdk');
The errors mentioned above appear when type-checking
npx tsc
Additional context
If, however, I set skipLibCheck: true in tsconfig.json, I get only the following error mentioned above (errors Module 'long' does not refer to a type disappear)
$ npx tscscripts.js:21:9 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@hashgraph/sdk")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to 'package.json'.21 require('@hashgraph/sdk'); ~~~~~~~~~~~~~~~~
The last version of the SDK is installed
$ npm why @hashgraph/sdk@hashgraph/[email protected] devnode_modules/@hashgraph/sdk dev @hashgraph/sdk@"^2.55.1" from the root project
Hedera network
other
Version
2.55.1
Operating system
macOS
The text was updated successfully, but these errors were encountered:
Description
When loading the SDK with
require('@hashgraph/sdk')
, I get a bunch of errors likeand the error
Steps to reproduce
In a new
npm
JavaScript project, add the SDK2.55.1
andtypescript
. Thepackage.json
'stype
is left untouched (it's usingcommonjs
as default.Use the following
tsconfig.json
Then create a minimal script that requires
@hashgraph/sdk
, for exampleThe errors mentioned above appear when type-checking
npx tsc
Additional context
If, however, I set
skipLibCheck: true
intsconfig.json
, I get only the following error mentioned above (errorsModule 'long' does not refer to a type
disappear)The last version of the SDK is installed
Hedera network
other
Version
2.55.1
Operating system
macOS
The text was updated successfully, but these errors were encountered: