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

VSCode Debug on windows SyntaxError: missing ) after argument list #27355

Closed
talohana opened this issue Oct 9, 2020 · 10 comments
Closed

VSCode Debug on windows SyntaxError: missing ) after argument list #27355

talohana opened this issue Oct 9, 2020 · 10 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby type: documentation An issue or pull request for improving or updating Gatsby's documentation

Comments

@talohana
Copy link
Contributor

talohana commented Oct 9, 2020

Description

I've tried to debug the build process following the docs - VS Code Debugger (Manual Config), after saving and running Gatsby develop config I got the following error:

C:\devl\workspace\my-project\node_modules\.bin\gatsby:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
←[90m    at wrapSafe (internal/modules/cjs/loader.js:1053:16)←[39m       
←[90m    at Module._compile (internal/modules/cjs/loader.js:1101:27)←[39m
←[90m    at Object..js (internal/modules/cjs/loader.js:1157:10)←[39m     
←[90m    at Module.load (internal/modules/cjs/loader.js:985:32)←[39m
←[90m    at Function._load (internal/modules/cjs/loader.js:878:14)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m

I workaround this by changing the config to:

{
    "name": "Gatsby develop",
    "type": "pwa-node",
    "request": "launch",
    "program": "${workspaceRoot}/node_modules/.bin/gatsby",
+    "windows": {
+    "program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby"
+    },
    "args": ["develop"],
    "runtimeArgs": ["--nolazy"],
    "console": "integratedTerminal"
},

It worked but logged Debugger attached. 4 times, which I'm not sure is the correct behavior.

Steps to reproduce

  1. gatsby new bug-repro https://github.com/gatsbyjs/gatsby-starter-hello-world

  2. add to .vscode/launch.json file:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Gatsby develop",
      "type": "pwa-node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/.bin/gatsby",
      "args": ["develop"],
      "runtimeArgs": ["--nolazy"],
      "console": "integratedTerminal"
    }
  ]
}

Environment

IDE: VSCode 1.49.3 x64 - using git-bash version 2.23.0.windows.1 as default terminal
System:
OS: Windows 10 10.0.19041
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Node: 12.18.3 - ~\AppData\Local\Temp\yarn--1602241778964-0.05746843170514704\node.CMD
Yarn: 1.22.4 - ~\AppData\Local\Temp\yarn--1602241778964-0.05746843170514704\yarn.CMD
npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.423.0), Chromium (85.0.564.70)
npmPackages:
gatsby: ^2.24.66 => 2.24.66
gatsby-image: ^2.4.20 => 2.4.20
gatsby-plugin-google-analytics: ^2.3.15 => 2.3.15
gatsby-plugin-manifest: ^2.4.32 => 2.4.32
gatsby-plugin-mdx: ^1.2.46 => 1.2.46
gatsby-plugin-offline: ^3.2.29 => 3.2.29
gatsby-plugin-react-helmet: ^3.3.12 => 3.3.12
gatsby-plugin-sharp: ^2.6.37 => 2.6.37
gatsby-plugin-styled-components: ^3.3.12 => 3.3.12
gatsby-plugin-typography: ^2.5.12 => 2.5.12
gatsby-remark-images: ^3.3.33 => 3.3.33
gatsby-remark-prismjs: ^3.5.16 => 3.5.16
gatsby-source-filesystem: ^2.3.31 => 2.3.31
gatsby-source-medium: ^2.3.12 => 2.3.12
gatsby-transformer-sharp: ^2.5.16 => 2.5.16

Would like to submit a PR is possible

@talohana talohana added the type: bug An issue or pull request relating to a bug in Gatsby label Oct 9, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 9, 2020
@vladar vladar added type: documentation An issue or pull request for improving or updating Gatsby's documentation and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 9, 2020
@zteric
Copy link
Contributor

zteric commented Oct 26, 2020

Any updates on this? having the same issue here

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 16, 2020
@github-actions
Copy link

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

@jtonneyck
Copy link

This command worked for me:
node --inspect node_modules/gatsby/dist/bin/gatsby develop

I'm running windows 10. Verified on Node 14.5.3 + 15.0 and gatsby 2.24.91 + 2.30.1.

@jtonneyck
Copy link

I see "debugger attached" only twice. There's just 1 node process running so I guess it's alright?

@arsinclair
Copy link

Why is this closed? What's the solution to the problem?

@arsinclair
Copy link

arsinclair commented Jan 18, 2021

Whilst this config works like a charm on Linux, on Windows 10 there's an exception. I've modified the config to use the direct path to gatsby distribution on Windows in the following way.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Gatsby develop",
      "type": "pwa-node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/.bin/gatsby",
      "windows": {
        "program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby"
      },
      "args": ["develop"],
      "runtimeArgs": ["--nolazy"],
      "console": "integratedTerminal"
    },
    {
      "name": "Gatsby build",
      "type": "pwa-node",
      "request": "launch",
      "program": "${workspaceRoot}/node_modules/.bin/gatsby",
      "windows": {
        "program": "${workspaceRoot}/node_modules/gatsby/dist/bin/gatsby"
      },
      "args": ["build"],
      "runtimeArgs": ["--nolazy"],
      "console": "integratedTerminal"
    }
  ]
}

@yonatanLehman
Copy link
Contributor

Same problem here. And the proposed solution works for me.
I have added it to the documentation at https://www.gatsbyjs.com/docs/debugging-the-build-process/ and issued a PR.

@arsinclair
Copy link

I think this can be added as a temporary measure. I think it is good to try to maintain the same configuration for all platforms. Really curious, why dirname crashes...

Thank you for your PR.

@zipzit
Copy link

zipzit commented Jun 26, 2021

I discovered this issue when searching for troubles in debugging in vscode. I started with

 "configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch via NPM",
        "runtimeExecutable": "npm",
        "runtimeArgs": [
            "run-script",
            "develop"
        ],
        "port": 9229,
        "skipFiles": [
            "<node_internals>/**"
        ]
    },

Total fail. No errors, the whole thing just hangs. Now I'm using the configurations from the website https://www.gatsbyjs.com/docs/debugging-the-build-process/ and that totally works. Many thanks!

One comment. When I'm looking at the new launch.json file in VSCode, there are a whole lot of warnings... Each of the configurations I copied from the link above generate four warnings:

Property windows is not allowed
missing property "name"
Missing property "type"
Missing property "request"

Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. type: bug An issue or pull request relating to a bug in Gatsby type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

No branches or pull requests

7 participants