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

tsconfig.json can no longer contain comments #11390

Closed
fabb opened this issue Mar 27, 2020 · 2 comments · Fixed by #11392
Closed

tsconfig.json can no longer contain comments #11390

fabb opened this issue Mar 27, 2020 · 2 comments · Fixed by #11392
Milestone

Comments

@fabb
Copy link
Contributor

fabb commented Mar 27, 2020

Bug report

Describe the bug

When the tsconfig.json contains comments /* */, npm run dev will fail.

This seems to be a regression in 9.3.2, it used to work in 9.2.1.

To Reproduce

  1. Have a tsconfig.json like this:
/* note that next.js currently cannot be configured to use another file than tsconfig.json, therefore we cannot rename it */
{
    "extends": "./tsconfig.base.json",
    "compilerOptions": {
        "jsx": "preserve",
        "lib": [
            "dom",
            "es2015",
            "es2016.array.include"
            /* this is set to a low target lib on purpose, because we do not polyfill modern browsers (only old ones like IE11) - only use modern api after checking if it's safe for the browsers we support */
        ],
        "module": "esnext",
        "noEmit": true
    },
    "exclude": [".server", "dist", ".next", "out", "next.config.js", "node_modules/**/*", "server"],
    "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
  1. Run npm run dev

  2. Observe error:

(node:15019) UnhandledPromiseRejectionWarning: SyntaxError: ./tsconfig.json: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1005:27)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at getBaseWebpackConfig (./node_modules/next/dist/build/webpack-config.js:8:28)
    at async Promise.all (index 0)
    at HotReloader.start (./node_modules/next/dist/server/hot-reloader.js:14:1788)
    at DevServer.prepare (./node_modules/next/dist/server/next-dev-server.js:6:1541)

Expected behavior

npm run dev should start without errors.

System information

  • OS: macOs Catalina
  • Version of Next.js: 9.3.2
@timneutkens
Copy link
Member

timneutkens commented Mar 27, 2020

Thanks for the report! Opened a PR to fix it: #11392

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants