Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Recommended VSCode debug launch.json

default discord avatar
gregwhitworth2 years ago
3

So I'm hitting some server issues and I'd really like to try and debug what is happening in Payload. I've leveraged the default Node JS launch.js which is:



{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "skipFiles": [ "<node_internals>/**" ], "program": "${workspaceFolder}\\src\\server.ts", "outFiles": [ "${workspaceFolder}/**/*.js" ] } ] }

But I get the following error when I run the debugger:



Process exited with code 1 Uncaught SyntaxError C:\Users\gregw\git\user-settings\src\server.ts:1 import express from 'express' ^^^^^^ SyntaxError: Cannot use import statement outside a module at compileFunction (vm:352:18) at wrapSafe (internal/modules/cjs/loader:1032:15) at Module._compile (internal/modules/cjs/loader:1067:27) at Module._extensions..js (internal/modules/cjs/loader:1155:10) at Module.load (internal/modules/cjs/loader:981:32) at Module._load (internal/modules/cjs/loader:822:12) at executeUserEntryPoint (internal/modules/run_main:77:12) at <anonymous> (internal/main/run_main_module:17:47)

TIA

  • discord user avatar
    jarrod_not_jared
    2 years ago

    Hey

    @612318753635565792

    where did you find that snippet? What exactly are you attempting to debug?



    Here is a snippet we use to launch test directories:


    {
      "version": "0.2.0",
      "configurations": [
        {
          "type": "node",
          "request": "launch",
          "name": "Launch Program",
          "runtimeArgs": [
            "-r",
            "ts-node/register"
          ],
          "args": [
            "${workspaceFolder}/test/dev.ts",
            "fields"
          ]
        },
      ]
    }


    Can also be found here:

    https://github.com/payloadcms/payload/blob/master/.vscode/launch.json
  • default discord avatar
    taun21602 years ago
    @612318753635565792

    , did you solve? I'm also receiving a SyntaxError: Cannot use import statement outside a module error

  • default discord avatar
    techinvertedlast year
    @479030528084017165

    follow the link

    @281120856527077378

    has shared. works perfectly

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.