import ES module
Following the guide, after successful yarn graphclient build I get stuck at import { execute } from '../.graphclient' .
- If running as JS : SyntaxError: Cannot use import statement outside a module
- If as .mjs : Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import './graphclient' is not supported resolving ES modules
How should it be correctly?
As the error states, directory imports are not supported when resolving ESM modules. Try importing .graphclient/index.(m)js instead.
As the error states, directory imports are not supported when resolving ESM modules. Try importing
.graphclient/index.(m)jsinstead.
Thanks but there I only have .ts, and if I start my script with import { execute } from '../.graphclient/index.ts', then: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /root/opt/GETbc/.graphclient/index.ts
Could you please guide me further?
Try without extension 🤔
Also, please share the version you're using. Thanks!
Try without extension 🤔
Also, please share the version you're using. Thanks!
Don't you need to compile .graphclient/index.ts alongside your application sources? Check the include option in tsconfig.json.
Oh you're not compiling. Yes, you need to compile. You cant import raw TS files.
yarn run tsc found 1047 errors in 30 files. 😭
Soo I tried to recreate exactly this guide in a subdir, but after both
- yarn add -D @graphprotocol/client-cli
- npm install --save-dev @graphprotocol/client-cli
, including installing @graphprotocol/[email protected],
graphclient buildreturnsgraphclient: command not foundWhy? 🤔