SyntaxError when running hasura command with yarn v2
DanNeish opened this issue · comments
I am getting the following error when trying to run the hasura command with yarn v2:
yarn hasura
/Users/dan/Projects/playground/test-yarn-2/node_modules/hasura-cli/hasura:1
����
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
I have tried with both hasura-cli v1.3.3 & 2.0.0-alpha.10
Setup steps:
mkdir test-yarn-v2
cd test-yarn-v2
npm init
yarn set version berry
Add nodeLinker: node-modules
to .yarnrc.yml file
yarn install
yarn add hasura-cli
yarn hasura
Any ideas on what might be causing this issue?
@DanNeish Hi!
Thanks for reporting the issue!
I haven't used yarn v2 yet.
Is this issue still valid?
Or have you found any useful information since then?
You can also share any guesswork even if not so sure.
I guess it may be caused by the fact that yarn v2 does not execute postinstall
hook like the way yarn v1 does.
To my looking over the docs, it seems a result of postinstall
hook is cached, which, I guess, might lead to an issue.
How do you think? Can you share a experimentation if possible?
Thanks!
I also have this problem. Install hasura-cli
, just try running it (yarn run hasura
), it fails
Just tried uninstalling then reinstalling (triggering a fresh build of hasura-cli
), that didn't change anything
BTW the OP's instructions are pretty straightforward, if you run literally what he said on your machine it seems to happen (on my M1 Macbook Air).
@jjangga0214 This is still an issue. My current workaround is installing hasura-cli globally which is not ideal.
Were you able to recreate the issue by following the steps I listed in my original post?
Any updates on this issue? Having the exact same problem as @DanNeish
@drojkind I plan to resolve this in near future. Sorry if this sounds too vague. I have been using yarn v1 mainly, so need some (uncertain amount of) time to research and experiment. That's why I labeled this issue as help wanted
.
Actually, I wanted to solve this earlier(about a month ago), but have had a busy time recently.
Anyway, I'd like to certainly say this issue is in my mind with high priority.
just checking in on this, as it's been a while - wondering if anyone has insights into how this may be resolved. thanks!
@jjangga0214 any findings on this? Just got hit by this today using yarn 2.
I have hasura metadata export
as script in package.json and if executed via yarn 2 I get the SyntaxError: Invalid or unexpected token
. However if I execute the exact same command directly in shell ./node_modules/hasura-cli/hasura metadata export
it works perfectly. This somewhat tells the install itself is not a problem just the execution via yarn 2.
actually adding the ./node_modules/hasura-cli/
prefix to all hasura commands in package.json get's this fixed. Dunno if yarn 2 has some special handling that yarn 1 didn't have.
A workaround is to add "hasura": "$(yarn bin hasura)"
to your package.json
as mentioned here: yarnpkg/berry#882 (comment)
This probably won't work on Windows, though.
Thanks @Osman-Sodefa, ended up using your workaround! (this is still an issue btw)