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"
}
๋ชจ๋ ํ์ฅ์ด ๋นํ์ฑํ ๋ ๊ฒฝ์ฐ์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๊น? : ์
์ด๊ฒ์ ์์ง ์ง์๋์ง ์๋ ๋ณต์กํ ์ค์ ์ ๋๋ค.
์์ ๊ตฌ์ฑ์์ "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
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์์ ๊ตฌ์ฑ์์
"console": "integratedTerminal"
์ ์ ๊ฑฐ ํ ๋ ์ด๊ฒ์ด ์๋ ํ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค."useWSL": true
์ด๋ฉด ์ถฉ๋ถํฉ๋๋ค.์ด๋ฌํ ์ค์ ์ ๋๋ฒ๊น ํ๊ธฐ ์ํด ํ์ฅ WSL workspaceFolder๋ฅผ ์ฌ์ฉํ๊ณ ๋ด lauch ๊ตฌ์ฑ์ ๋ค์์ ์ถ๊ฐํฉ๋๋ค.
๋๋ฅผ ์ํด ์๋ํ๋ ์ :
mocha ํ ์คํธ๋ฅผ ๋๋ฒ๊ทธํ๊ธฐ ์ํด ๋ค์ ์์ ๊ตฌ์ฑ์ ์ฌ์ฉํฉ๋๋ค.
์ฐธ๊ณ : ์ถ๋ ฅ์ "๋๋ฒ๊ทธ ์ฝ์"ํญ์ ์์ต๋๋ค.