hasura / hasura/graphql-engine

"hasura init" failed. (Invalid or unexpected token)

Open
#7,678 2 comments 2 reactions 0 assignees View on GitHub
c/cli k/bug support/needs-more-info
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: v2.0.9 (hasura/graphql-engine:v2.0.9)
CLI Version (for CLI related issue): v2.0.9 ("hasura-cli": "^2.0.9",)

### Environment

OSS

### What is the expected behaviour?

Initialize hasura project by cli successfully.

### Keywords

Invalid or unexpected token

### What is the current behaviour?

Run hasura init, an error `SyntaxError: Invalid or unexpected token` occured.

```
$ HASURA_GRAPHQL_ADMIN_SECRET=mysecret yarn run hasura init api --endpoint http://127.0.0.1:8080
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:988:16)
at Module._compile (internal/modules/cjs/loader.js:1036:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47

```

### How to reproduce the issue?

1. Create docker-compose.yml.
2. Run `docker-compose up`
3. Run `yarn add -D hasura-cli`
4. `HASURA_GRAPHQL_ADMIN_SECRET=mysecret yarn run hasura init api --endpoint http://127.0.0.1:8080`

`docker-compose.yml`

```yml
version: "3.7"

services:
database:
container_name: myappDB
image: postgres:13.4-alpine
restart: always
volumes:
- postgresdata:/var/lib/postgresql/data
environment:
POSTGRES_DB: myapp
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
graphql-engine:
image: hasura/graphql-engine:v2.0.9
ports:
- "8080:8080"
depends_on:
- database
restart: always
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://user:password@database:5432/myapp
PG_DATABASE_URL: postgres://user:password@database:5432/myapp
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_ADMIN_SECRET: mysecret

volumes:
postgresdata:
name: myapp-postgres-data
```

### Screenshots or Screencast

N/A

### Please provide any traces or logs that could help here.

N/A

### Any possible solutions?

N/A

### Can you identify the location in the source code where the problem exists?

N/A

### If the bug is confirmed, would you be willing to submit a PR?

I don't have any idea for resolving it.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using the reported `yarn run hasura init api --endpoint http://127.0.0.1:8080` command after starting the supplied docker-compose.yml. Start from the Hasura CLI entry point and the Node.js stack trace; done means `hasura init` successfully initializes the project without the syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, node.js, typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.