Vscode: WSL์„ ์‚ฌ์šฉํ•˜์—ฌ Node ํ”„๋กœ๊ทธ๋žจ์„ ๋””๋ฒ„๊น… ํ•  ์ˆ˜ ์—†์Œ

์— ๋งŒ๋“  2018๋…„ 07์›” 18์ผ  ยท  4์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: microsoft/vscode


  • VSCode ๋ฒ„์ „ : 1.25.1
  • OS ๋ฒ„์ „ : Windows 10 Home 1803

Linux ์šฉ Windows Subsytem์„ ์‚ฌ์šฉํ•˜์—ฌ Node ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์„ ๋””๋ฒ„๊น…ํ•˜๋ ค๊ณ ํ•˜๋Š”๋ฐ ๊ฒฝ๋กœ๊ฐ€ ๋ฒˆ์—ญ๋˜๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ด๊ฒƒ์€ ๋‚ด launch.json์ž…๋‹ˆ๋‹ค.

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch NestJS",
      "useWSL": true,
      "console": "integratedTerminal",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run-script",
        "start:dev"
      ],
      "port": 5000,
    }
  ]
}

๊ทธ๋ฆฌ๊ณ  ์ด๊ฒƒ์€ ๋””๋ฒ„๊ทธ๋ฅผ ์‹œ๋„ํ•œ ํ›„ ๋‚ด ์ฝ˜์†”์— ๋‚˜ํƒ€๋‚˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

isiah@isiah-acer:/mnt/c/Users/Isiah/Documents/Programming_Projects/etc/podcast_db/new-api$ cd "c:\Users\Isiah\Documents\Programming_Projects\etc\podcast_db\new-api" ; "C:\WINDOWS\System32\bash.exe" -ic "npm run-script start:dev"
-bash: cd: c:\Users\Isiah\Documents\Programming_Projects\etc\podcast_db\new-api: No such file or directory
C:\WINDOWS\System32\bash.exe: command not found

์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ์œ„ํ•ด npm run-script start:dev ๋Š” nodemon ํ•˜๊ณ  ์—ฌ๊ธฐ์— ๋‚ด nodemon.json์ด ์žˆ์Šต๋‹ˆ๋‹ค.

{
  "watch": [
    "src"
  ],
  "ext": "ts",
  "ignore": [
    "src/**/*.spec.ts"
  ],
  "exec": "node -r tsconfig-paths/register --inspect=5000 --require ts-node/register src/main.ts"
}


๋ชจ๋“  ํ™•์žฅ์ด ๋น„ํ™œ์„ฑํ™” ๋œ ๊ฒฝ์šฐ์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๊นŒ? : ์˜ˆ

WSL bug debug verified

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์‹œ์ž‘ ๊ตฌ์„ฑ์—์„œ "console": "integratedTerminal" ์„ ์ œ๊ฑฐ ํ•  ๋•Œ ์ด๊ฒƒ์ด ์ž‘๋™ ํ•  ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. "useWSL": true ์ด๋ฉด ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ์„ค์ •์„ ๋””๋ฒ„๊น…ํ•˜๊ธฐ ์œ„ํ•ด ํ™•์žฅ WSL workspaceFolder๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๋‚ด lauch ๊ตฌ์„ฑ์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

"localRoot": "${workspaceFolder}",
"remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",

๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•˜๋Š” ์˜ˆ :

{
  "type": "node",
  "request": "launch",
  "name": "Run NPM script in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "runtimeExecutable": "npm",
  "runtimeArgs": [
    "run-script",
    "foo",
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

mocha ํ…Œ์ŠคํŠธ๋ฅผ ๋””๋ฒ„๊ทธํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ์‹œ์ž‘ ๊ตฌ์„ฑ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

{
  "type": "node",
  "request": "launch",
  "name": "Run mocha tests in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": [
    "-u",
    "tdd",
    "--timeout",
    "999999",
    "--colors",
    "--exit",
    "${command:extension.vscode-wsl-workspaceFolder}/tests/test.js"
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

์ฐธ๊ณ  : ์ถœ๋ ฅ์€ "๋””๋ฒ„๊ทธ ์ฝ˜์†”"ํƒญ์— ์žˆ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  4 ๋Œ“๊ธ€

์ด๊ฒƒ์€ ์•„์ง ์ง€์›๋˜์ง€ ์•Š๋Š” ๋ณต์žกํ•œ ์„ค์ •์ž…๋‹ˆ๋‹ค.

์‹œ์ž‘ ๊ตฌ์„ฑ์—์„œ "console": "integratedTerminal" ์„ ์ œ๊ฑฐ ํ•  ๋•Œ ์ด๊ฒƒ์ด ์ž‘๋™ ํ•  ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. "useWSL": true ์ด๋ฉด ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ์„ค์ •์„ ๋””๋ฒ„๊น…ํ•˜๊ธฐ ์œ„ํ•ด ํ™•์žฅ WSL workspaceFolder๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๋‚ด lauch ๊ตฌ์„ฑ์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

"localRoot": "${workspaceFolder}",
"remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",

๋‚˜๋ฅผ ์œ„ํ•ด ์ž‘๋™ํ•˜๋Š” ์˜ˆ :

{
  "type": "node",
  "request": "launch",
  "name": "Run NPM script in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "runtimeExecutable": "npm",
  "runtimeArgs": [
    "run-script",
    "foo",
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

mocha ํ…Œ์ŠคํŠธ๋ฅผ ๋””๋ฒ„๊ทธํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ์‹œ์ž‘ ๊ตฌ์„ฑ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

{
  "type": "node",
  "request": "launch",
  "name": "Run mocha tests in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": [
    "-u",
    "tdd",
    "--timeout",
    "999999",
    "--colors",
    "--exit",
    "${command:extension.vscode-wsl-workspaceFolder}/tests/test.js"
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

์ฐธ๊ณ  : ์ถœ๋ ฅ์€ "๋””๋ฒ„๊ทธ ์ฝ˜์†”"ํƒญ์— ์žˆ์Šต๋‹ˆ๋‹ค.

@ n0v1 ๋‚˜๋ฅผ ์œ„ํ•ด ์ผํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

์ด๊ฒƒ์€ ์ด์ œ WSL์—์„œ ๊ฐœ๋ฐœํ•˜๋Š” ์ผ๋ฐ˜์ ์ธ ์‚ฌ์šฉ ์‚ฌ๋ก€์ด๋ฉฐ ๋””๋ฒ„๊น… ์ž‘์—…์ด ์ œ ์ž‘์—…์— ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด์ œ ํŒŒ์ด์ฌ์„ ์ž‘๋™ ์‹œํ‚ค๋ ค๋ฉด ๐Ÿคž

VS Code๋ฅผ ์‚ฌ์šฉํ•œ ์›๊ฒฉ ๊ฐœ๋ฐœ์„ ๋ฐฉ๊ธˆ ๋ฐœํ‘œํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๋ฌผ์„ ํ™•์ธํ•˜์„ธ์š”. https://code.visualstudio.com/blogs/2019/05/02/remote-development

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰