Skip to content

JSON error when run command #5

Open

Description

@brunogusta

Package version

@adonisjs/upgrade-kit@1.4.0

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

Activity

  1. samuel-s-marques commented on Feb 7, 2024

    @samuel-s-marques

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

  2. RomainLanz commented on Feb 7, 2024

    @RomainLanz
    Member

    Hey both of you! 👋🏻

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

  3. samuel-s-marques commented on Feb 7, 2024

    @samuel-s-marques

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

  4. self-assigned this
    on Feb 19, 2024
  5. Julien-R44 commented on Feb 19, 2024

    @Julien-R44
    Member

    sorry I missed that issue. i will take a look

  6. Julien-R44 commented on Feb 20, 2024

    @Julien-R44
    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

  7. royvanderzon commented on Feb 24, 2024

    @royvanderzon

    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.

  8. redareda9 commented on Feb 29, 2024

    @redareda9

    Same problem here.

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

  9. Julien-R44 commented on Feb 29, 2024

    @Julien-R44
    Member

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

  10. D40298008 commented on Mar 4, 2024

    @D40298008

    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions