hasura-cli
hasura-cli copied to clipboard
Error exporting metadata
Hi!
Im trying to configure hasura console to manage migrations.
I've tested the binary for linux and the npm package, but the error is the same.
npx hasura-cli metadata export
FATA[0000] failed to export metadata: cannot export actions from metadata: error parsing metadata
object: actions
file: actions.yaml
error: error in converting metadata to sdl: exit status 1: internal/modules/package_json_reader.js:4
const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
^
TypeError: require(...).internalModuleReadJSON is not a function
at internalModuleReadJSON (internal/modules/package_json_reader.js:4:68)
at Object.read (internal/modules/package_json_reader.js:19:34)
at readPackage (internal/modules/cjs/loader.js:237:36)
at readPackageScope (internal/modules/cjs/loader.js:270:19)
at trySelf (internal/modules/cjs/loader.js:386:40)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:24)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at Module._preloadModules (internal/modules/cjs/loader.js:1147:12)
at loadPreloadModules (internal/bootstrap/pre_execution.js:451:5)
Enviroment
- SO: Ubuntu 20.04 over WSL in Windows 11
- Node: 14.16.1 (tested on 12 & 16)
- Npm: 7.17.0
@bernatvadell I get this exact same error, but only if I run it in VSCode. If I use WindowsTerminal to open my Ubuntu shell and run it from there, it works.
@bernatvadell @jrobber Hi! Thank you for reporting the issue! May I ask if this happens with the latest version? (I personally don't use/have a Windows machine (though I may be able to use VM if necessary), so I'd like you to test if possible)
Thanks!
I am also curious whether npx hasura-cli metadata export
and npx hasura metadata export
can have different results.
I 'guess', theoretically, some of these scenarios may be possible. (I don't know if CLI can be executed both on WSL and Windows regardless of how it was installed.)
@bernatvadell @jrobber Would you advise which are possible and which you can test?
Thanks!
-
'1'. Install package manager(e.g. npm) on Windows (not WSL),
- 1.1. and execute
npm install
on Windows shell (command prompt of CMD or Powershell),- 1.1.1. and execute
npx hasura-cli metadata export
- 1.1.1.1. on WSL
- 1.1.1.2. on Windows
- 1.1.2. and execute
npx hasura metadata export
- 1.1.2.1. on WSL
- 1.1.2.2. on Windows
- 1.1.1. and execute
- 1.2. and execute
npm install
on WSL- 1.2.1. and execute
npx hasura-cli metadata export
- 1.2.1.1. on WSL
- 1.2.1.2. on Windows
- 1.2.2. and execute
npx hasura metadata export
- 1.2.2.1. on WSL
- 1.2.2.2. on Windows
- 1.2.1. and execute
- 1.1. and execute
-
'2'. Install package manager(e.g. npm) on WSL(not Windows),
- 2.1. and execute
npm install
on Windows shell (command prompt of CMD or Powershell),- 2.1.1. and execute
npx hasura-cli metadata export
- 2.1.1.1. on WSL
- 2.1.1.2. on Windows
- 2.1.2. and execute
npx hasura metadata export
- 2.1.2.1. on WSL
- 2.1.2.2. on Windows
- 2.1.1. and execute
- 2.2. and execute
npm install
on WSL- 2.2.1. and execute
npx hasura-cli metadata export
- 2.2.1.1. on WSL
- 2.2.1.2. on Windows
- 2.2.2. and execute
npx hasura metadata export
- 2.2.2.1. on WSL
- 2.2.2.2. on Windows
- 2.2.1. and execute
- 2.1. and execute
@jrobber
I get this exact same error, but only if I run it in VSCode. If I use WindowsTerminal to open my Ubuntu shell and run it from there, it works.
Maybe, that's because VSCode changes the environment, like by adding NODE_OPTIONS
or so. Let me know if you know/find some information!
I had the same issue with applying metadata to the GraphQL engine when running from VSCode's integrated terminal. When run from the standard macOS terminal it worked fine. I was running Hasura commands from VSCode without any issues just until recently so maybe it's connected to the VSCode version (it automatically installs updates on my machine)?
VSCode version: 1.73.1 Hasura CLI version: 2.6.1
Had the same issue. I'm running Visual Studio Code Version 1.91.0.
Disabling Auto Attach works as a workaround for me. To re-enable it, execute the Debug: Toggle Auto Attach command from the Command Palette and set it to whatever it was previously. Choosing Temporarily disable auto attach in this session to disable it temporarily does not work.
Don't forget to relaunch the integrated terminal for the disabling to take effect.
For me Auto Attach being enabled, or temporarily disabled, adds the following to my environment:
$ echo $NODE_OPTIONS
--require /home/user/.config/Code/User/workspaceStorage/ee7680bfac58bb7fb0b18d6be57f57bb/ms-vscode.js-debug/bootloader.js
Which seems, to me, to be the cause somehow. When Auto Attach is disabled NODE_OPTIONS
is empty.
Linux 6.9.7 Hasura CLI: 2.40.2 Node: 22.2.0 VSCode: 1.91.0