Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON error when run command #5

Open
brunogusta opened this issue Feb 3, 2024 · 9 comments
Open

JSON error when run command #5

brunogusta opened this issue Feb 3, 2024 · 9 comments
Assignees

Comments

@brunogusta
Copy link

brunogusta commented Feb 3, 2024

Package version

@adonisjs/[email protected]

Describe the bug

image

I had this bug when try to update the version.

Node version used: v20.9.0

I tried installing the package with pnpm, npm and yarn. With yarn I get a node version error... and the others I get the error above when execute the command.

Reproduction repo

No response

@samuel-s-marques
Copy link

Yep. Same here. SyntaxError: Unexpected token } in JSON at position 497.

@RomainLanz
Copy link
Member

Hey both of you! 👋🏻

Is it possible to share the repository where you try to run the command?

@samuel-s-marques
Copy link

Hey! I'm trying to run on thisdatedoesnotexist-server. It's still using AdonisJS v5. I'm trying to update it to v6.

@Julien-R44 Julien-R44 self-assigned this Feb 19, 2024
@Julien-R44
Copy link
Member

sorry I missed that issue. i will take a look

@Julien-R44
Copy link
Member

@samuel-s-marques can you give more information? I just tried to run upgrade-kit on your repo and it seems to works fine. Can you give your node version and also the command/patch you ran?

I'm using Node 21.6

@royvanderzon
Copy link

royvanderzon commented Feb 24, 2024

I had the same problem and found this code in upgrade-kit/src/runner.ts

loader.update('Loading config files')
    this.#patchers = this.#options.patchers.map((factory) => factory(this))
    this.rcFile = new RcFile(join(this.#options.projectPath, '.adonisrc.json'))
    this.tsConfigFile = new Tsconfig(join(this.#options.projectPath, 'tsconfig.json'))
    this.pkgJsonFile = new PkgJson(join(this.#options.projectPath, 'package.json'))

For me the problem was that in my tsconfig.json a line was commeted out:

{
    "extends": "adonis-preset-ts/tsconfig.json",
    "include": ["**/*"],
    "exclude": ["node_modules", "build"],
    "compilerOptions": {
        "outDir": "build",
        "rootDir": "./",
        "sourceMap": true,
        "paths": {
            "App/*": ["./app/*"],
            "Config/*": ["./config/*"],
            "Contracts/*": ["./contracts/*"],
            "Database/*": ["./database/*"]
            // "@ioc:/*": ["./contracts/*"]  <------ remove this line
        },
        "types": [
            "@adonisjs/core",
            "@adonisjs/repl",
            "@japa/preset-adonis/build/adonis-typings",
            "@adonisjs/lucid",
            "@adonisjs/auth",
            "adonis5-jwt",
            "@adonisjs/session",
            "@adonisjs/mail",
            "@adonisjs/drive-s3"
        ]
    }
}

There are multiple .json configs so it could be that you need to check the other config files as well (.adonisrc.json, tsconfig.json, package.json).

This fixed the error for me. I also had another error message but it resolved after I upgraded to node v21.

@redareda9
Copy link

Same problem here.

@royvanderzon's solution didn't work. I had no comments in any of my json files.

@Julien-R44
Copy link
Member

Julien-R44 commented Feb 29, 2024

i need a repro or at least more informations. otherwise there's nothing I can do to help

@D40298008
Copy link

I had a similar issue and it wasn't a comment that was causing the problem, but the last element of an object in my tsconfig.json had a comma (,)...so it was expecting a new line. VSCode wasn't complaining so it went unnoticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants