Note
ãã®ãã¼ã¸ã«ã¢ã¯ã»ã¹ããã«ã¯ãæ¿èªãå¿ è¦ã§ãã ãµã¤ã³ã¤ã³ã¾ãã¯ãã£ã¬ã¯ããªã®å¤æ´ã試ããã¨ãã§ãã¾ãã
ãã®ãã¼ã¸ã«ã¢ã¯ã»ã¹ããã«ã¯ãæ¿èªãå¿ è¦ã§ãã ãã£ã¬ã¯ããªã®å¤æ´ã試ããã¨ãã§ãã¾ãã
ãã®ã¬ã¤ãã¯ãWindows éçºç°å¢ã« Node.js ãã¤ã³ã¹ãã¼ã«ããã®ã«å½¹ç«ã¡ã¾ãã
Linux ç°å¢ã§ Node.js ã使ç¨ããå ´åã¯ããLinux ç¨ Windows ãµãã·ã¹ãã (WSL2)ã« Node.js ãã¤ã³ã¹ãã¼ã«ããããåç §ãã¦ãã ããã
ã¤ã³ã¹ãã¼ã«ããå ´æã¨ããã¤ãã£ã Windows ç°å¢ã¨ Linux (WSL 2) ç°å¢ã§ Node.js ã使ç¨ãã¦éçºãããã©ãããæ±ºå®ããã¨ãã¯ã次ã®ç¹ãèæ ®ãã¦ãã ããã
ã¹ãã«ã¬ãã«ã® : Node.js ã使ã£ãéçºãåãã¦è¡ããããã«èµ·åãã¦å¦ç¿ã§ããããã«å®è¡ãããå ´åã¯ãWindowsã« Node.js ãã¤ã³ã¹ãã¼ã«ã Windows ã« Node.js ãã¤ã³ã¹ãã¼ã«ãã¦ä½¿ç¨ããã¨ãWSL ã使ç¨ãããããåå¿è åãã®è¤éãªç°å¢ãæä¾ããã¾ãã - ã³ãã³ã ã©ã¤ã³ ã¯ã©ã¤ã¢ã³ã ãã¼ã«ã®: PowerShell ã使ç¨ããå ´åã¯ãWindows ã§ Node.js ã使ç¨ãã¾ãã Bash ã使ç¨ããå ´åã¯ãNode.js on Linux (WSL 2) ã使ç¨ãã¾ãã
- éç¨ãµã¼ãã¼: Windows Server ã« Node.js ã¢ããªãå±éããäºå®ã®å ´åã¯ãWindows ã§ Node.js ã使ç¨ãã¾ãã Linux Server ã«ãããã¤ããäºå®ã®å ´åã¯ãNode.js on Linux (WSL 2) ã使ç¨ãã¾ãã WSL ã使ç¨ããã¨ã好ã¿ã® Linux ãã£ã¹ããªãã¥ã¼ã·ã§ã³ (æ¢å®ã¨ã㦠Ubuntu ã使ç¨) ãã¤ã³ã¹ãã¼ã«ããéçºç°å¢ (ã³ã¼ããè¨è¿°ããå ´æ) ã¨éç¨ç°å¢ (ã³ã¼ãããããã¤ããã¦ãããµã¼ãã¼) ã®éã®ä¸è²«æ§ã確ä¿ã§ãã¾ãã
-
ããã©ã¼ãã³ã¹ã®é度ã¨ã·ã¹ãã å¼ã³åºãã®äºææ§: Linux 㨠Windows ã®ããã©ã¼ãã³ã¹ã§ã¯ç¶ç¶çãªè°è«ã¨éçºãããã¾ãããWindows ãã·ã³ã使ç¨ããå ´åã®éµã¯ãNode.jsãã¤ã³ã¹ãã¼ã«ããã®ã¨åããã¡ã¤ã« ã·ã¹ãã ã«éçºããã¸ã§ã¯ã ãã¡ã¤ã«ãä¿æãããã¨ã§ãã Windows ãã¡ã¤ã« ã·ã¹ãã ã« Node.js ãã¤ã³ã¹ãã¼ã«ããå ´åã¯ããã¡ã¤ã«ã Windows ãã©ã¤ã (C:/ãªã©) ã«ä¿æãã¾ãã Node.js ã Linux ãã£ã¹ããªãã¥ã¼ã·ã§ã³ (Ubuntu ãªã©) ã«ã¤ã³ã¹ãã¼ã«ããå ´åã¯ã使ç¨ãã¦ãããã£ã¹ããªãã¥ã¼ã·ã§ã³ã«é¢é£ä»ãããã¦ãã Linux ãã¡ã¤ã« ã·ã¹ãã ãã£ã¬ã¯ããªã«ããã¸ã§ã¯ã ãã¡ã¤ã«ãä¿æãã¾ãã (WSL é
å¸ã³ãã³ã ã©ã¤ã³ãã
explorer.exe .ãå ¥åããWindows ã¨ã¯ã¹ããã¼ã©ã¼ã使ç¨ãã¦ãã£ã¬ã¯ããªãåç §ãã¾ã)ã Docker ã³ã³ããã¼ : Docker ã³ã³ããã¼ã使ç¨ã㦠Windows ã§ããã¸ã§ã¯ããéçºããå ´åã¯ãWindowsã« Docker Desktop ãã¤ã³ã¹ãã¼ã«ãããã¨ããå§ããã¾ãã Linux ã¯ã¼ã¯ã¹ãã¼ã¹ã§ Docker ã使ç¨ããã«ã¯ãLinux 㨠Windows ã®ä¸¡æ¹ã®ãã«ã ã¹ã¯ãªãããç¶æããå¿ è¦ããªãããã«ãWSL 2 ã使ç¨ã㦠Windows ç¨ Docker Desktop ãè¨å®ãã ãåç §ãã¦ãã ããã
nvm-windowsãnode.jsãããã³ npm ãã¤ã³ã¹ãã¼ã«ãã
Windows ã¾ã㯠WSL ã«ã¤ã³ã¹ãã¼ã«ãããã©ããã鏿ããã ãã§ãªããNode.jsãã¤ã³ã¹ãã¼ã«ããã¨ãã«è¿½å ã®é¸æè¢ãããã¾ãã ãã¼ã¸ã§ã³ã®å¤æ´ãéå¸¸ã«æ©ãå ´åã¯ããã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã使ç¨ãããã¨ããå§ããã¾ãã 使¥ãã¦ãããã¾ãã¾ãªããã¸ã§ã¯ãã®ãã¼ãºã«åºã¥ãã¦ãè¤æ°ã® Node.js ãã¼ã¸ã§ã³ãåãæ¿ããå¿ è¦ãããå¯è½æ§ãããã¾ãã ãã¼ã ãã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã¯ãããä¸è¬çã« nvm ã¨å¼ã°ããè¤æ°ã®ãã¼ã¸ã§ã³ã® Node.jsãã¤ã³ã¹ãã¼ã«ããæãä¸è¬çãªæ¹æ³ã§ãããMac/Linux ã§ã®ã¿ä½¿ç¨ã§ããWindows ã§ã¯ãµãã¼ãããã¦ãã¾ããã 代ããã«ãnvm-windows ãã¤ã³ã¹ãã¼ã«ããããã使ç¨ã㦠Node.js ã¨ãã¼ã ããã±ã¼ã¸ ããã¼ã¸ã£ã¼ (npm) ãã¤ã³ã¹ãã¼ã«ãããã¨ããå§ããã¾ãã 代æ¿ã®ãã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã«ã¤ãã¦ãæ¤è¨ããå¿ è¦ãããã¾ããæ¬¡ã®ã»ã¯ã·ã§ã³ã§èª¬æãã¾ãã
éè¦
ãã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ãã¤ã³ã¹ãã¼ã«ããåã«ãNode.js ã¾ã㯠npm ã®æ¢åã®ã¤ã³ã¹ãã¼ã«ããªãã¬ã¼ãã£ã³ã° ã·ã¹ãã ããåé¤ãããã¨ããå§ããã¾ããã¤ã³ã¹ãã¼ã«ã®ç¨®é¡ãç°ãªãã¨ãå¥å¦ã§æ··ä¹±ããç«¶åãçºçããå¯è½æ§ãããããã§ãã ããã«ã¯ãæ®ã£ã¦ããå¯è½æ§ãããæ¢åã® Node.js ã¤ã³ã¹ãã¼ã« ãã£ã¬ã¯ã㪠(ä¾: "C:\Program Files\nodejs") ã®åé¤ãå«ã¾ãã¾ãã NVM ã§çæãããã·ã³ããªã㯠ãªã³ã¯ã¯ãæ¢åã® (空ã®) ã¤ã³ã¹ãã¼ã« ãã£ã¬ã¯ããªã䏿¸ããã¾ããã 以åã®ã¤ã³ã¹ãã¼ã«ãåé¤ããæ¹æ³ã«ã¤ãã¦ã¯ããWindowsãã node.js ãå®å ¨ã«åé¤ããæ¹æ³ããåç §ãã¦ãã ããã
è¦å
NVM ã¯ãã¦ã¼ã¶ã¼ãã¨ã«ã¤ã³ã¹ãã¼ã«ãããã·ã§ã«ãã¨ã«å¼ã³åºãããããã«è¨è¨ããã¦ãã¾ãã ããã¯ãè¤æ°ã®ãã«ã ã¨ã¼ã¸ã§ã³ããæã¤å
±æéçºè
ããã¯ã¹ããã«ã ãµã¼ãã¼ç¨ã«è¨è¨ããã¦ãã¾ããã NVM ã¯ã·ã³ããªã㯠ãªã³ã¯ã使ç¨ãã¦åä½ãã¾ãã å
±æã·ããªãªã§ nvm ã使ç¨ããã¨ããã®ãªã³ã¯ãã¦ã¼ã¶ã¼ã®ã¢ã㪠ãã¼ã¿ ãã©ã«ãã¼ãæãã¦ãããããåé¡ãçºçãã¾ãããã®ãããã¦ã¼ã¶ã¼ x ã nvm use ltså®è¡ããã¨ããªã³ã¯ã¯ããã¯ã¹å
¨ä½ã®ãã¼ããã¢ã㪠ãã¼ã¿ ãã©ã«ãã¼ã«ãã¤ã³ããã¾ãã ã¦ã¼ã¶ã¼ y ããã¼ãã¾ã㯠npm ãå®è¡ããå ´åãx ã®ã¦ã¼ã¶ã¼ ã¢ã«ã¦ã³ãã§ãã¡ã¤ã«ãå®è¡ããããã«æç¤ºãããnpm -gã®å ´å㯠x ã®ãã¡ã¤ã«ã夿´ãã¾ãããæ¢å®ã§ã¯è¨±å¯ããã¾ããã ãããã£ã¦ãnvmã¯1ã¤ã®éçºè
ããã¯ã¹ã«ã®ã¿è¦å®ããã¦ãã¾ãã ããã¯ãã«ã ãµã¼ãã¼ã«ãå½ããã¾ãã 2 ã¤ã®ãã«ã ã¨ã¼ã¸ã§ã³ããåã VM/ããã¯ã¹ä¸ã«ããå ´åããããã¯ç«¶åãããã«ãã§å¥å¦ãªåä½ãå¼ãèµ·ããå¯è½æ§ãããã¾ãã
nvm-windows ãªãã¸ããªã®ã¤ã³ã¹ãã¼ã«æé ã«å¾ãã¾ãã ã¤ã³ã¹ãã¼ã©ã¼ã使ç¨ãããã¨ããå§ããã¾ããããã¼ãºãããé«åº¦ã«çè§£ãã¦ããå ´åã¯ãæåã¤ã³ã¹ãã¼ã«ãæ¤è¨ãããã¨ããå§ããã¾ãã ã¤ã³ã¹ãã¼ã©ã¼ã¯ææ°ãã¼ã¸ã§ã³ã® ãªãªã¼ã¹ ãã¼ã¸ ã¸æ¡å ãã¾ãã
ææ°ã®ãªãªã¼ã¹ã® nvm-setup.zip ãã¡ã¤ã«ããã¦ã³ãã¼ããã¾ãã
ãã¦ã³ãã¼ãããããzip ãã¡ã¤ã«ãéããnvm-setup.exe ãã¡ã¤ã«ãéãã¾ãã
ã»ããã¢ãã NVM-for-Windows ã¤ã³ã¹ãã¼ã« ã¦ã£ã¶ã¼ãã§ã¯ãnvm-windows 㨠Node.js ã®ä¸¡æ¹ãã¤ã³ã¹ãã¼ã«ããããã£ã¬ã¯ããªã®é¸æãªã©ãã»ããã¢ããæé ã«ã¤ãã¦èª¬æãã¾ãã
ã¤ã³ã¹ãã¼ã«ãå®äºãããã PowerShell ãéã (管çè ç¹æ¨©ã§éãã®ããå§ããã¾ã)ãnvm-windows ã使ç¨ãã¦ãç¾å¨ã¤ã³ã¹ãã¼ã«ããã¦ãã Node ã®ãã¼ã¸ã§ã³ãä¸è¦§è¡¨ç¤ºãã¦ã¿ã¦ãã ãã (ãã®æç¹ã§ã¯åå¨ããªãå¿ è¦ãããã¾ã):
nvm ls
Node.js ã®ç¾å¨ã®ãªãªã¼ã¹ãã¤ã³ã¹ãã¼ã«ãã¾ã (ææ°ã®æ©è½æ¹åããã¹ãããããã§ãããLTS ãã¼ã¸ã§ã³ãããåé¡ãçºçããå¯è½æ§ãé«ããªãã¾ã):
nvm install latestNode.js ã®ææ°ã®å®å®ç LTS ãªãªã¼ã¹ï¼æ¨å¥¨ï¼ãã¤ã³ã¹ãã¼ã«ããã«ã¯ãã¾ã
nvm list availableã使ã£ã¦ç¾å¨ã® LTS ãã¼ã¸ã§ã³çªå·ã調ã¹ã¦ããããã®ãã¼ã¸ã§ã³çªå·ãnvm install <version>ã§ã¤ã³ã¹ãã¼ã«ãã¾ãï¼<version>ã該å½ã®çªå·ã«ç½®ãæãã¾ããä¾ãã°ï¼nvm install 12.14.0ï¼ã使ç¨å¯è½ãªãã¼ã¸ã§ã³ã® NVM ä¸è¦§ã

ã¤ã³ã¹ãã¼ã«ããã¦ãã Node ã®ãã¼ã¸ã§ã³ãä¸è¦§è¡¨ç¤ºãã¾ã:
nvm ls...ã¤ã³ã¹ãã¼ã«ãã 2 ã¤ã®ãã¼ã¸ã§ã³ãä¸è¦§è¡¨ç¤ºããã¾ãã
å¿ è¦ãª Node.js ãã¼ã¸ã§ã³çªå·ãã¤ã³ã¹ãã¼ã«ããããã
nvm use <version>ãã¨å ¥åãã¦ä½¿ç¨ãããã¼ã¸ã§ã³ã鏿ãã¾ã (<version>ãçªå·ã«ç½®ãæãã¾ããã¤ã¾ããnvm use 12.9.0)ãããã¸ã§ã¯ãã«ä½¿ç¨ãã Node.js ã®ãã¼ã¸ã§ã³ã夿´ããã«ã¯ãæ°ããããã¸ã§ã¯ããã£ã¬ã¯ããª
mkdir NodeTestã使ãããã£ã¬ã¯ããªcd NodeTestã«ç§»åãã¾ãããã®å¾ãnvm use <version>ã叿ãããã¼ã¸ã§ã³çªå· (ä¾: v10.16.3) ã«ç½®ãæãã¦ã<version>ãå®è¡ãã¾ããã¤ã³ã¹ãã¼ã«ããã¦ãã npm ã®ãã¼ã¸ã§ã³ã確èªãã¾ãã
npm --versionããã®ãã¼ã¸ã§ã³çªå·ã¯ãç¾å¨ã®ãã¼ã¸ã§ã³ã® Node.jsã«é¢é£ä»ãããã¦ãã npm ãã¼ã¸ã§ã³ã«èªåçã«å¤æ´ããã¾ãã
代æ¿ã®ãã¼ã¸ã§ã³ç®¡çãã¼ã«
NVM for Windows (nvm-windows) ã¯ç¾å¨ããã¼ãã§æãä¸è¬çãªãã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã§ãããæ¬¡ã®ç¹ãèæ ®ããå¿ è¦ãããã¾ãã
nvs (Node Version Switcher) ã¯ãVS Codeã¨çµ±åæ©è½ãåããã¯ãã¹ãã©ãããã©ã¼ã ã®ä»£æ¿ææ®µã§ãã Volta ã¯ãLinkedIn ãã¼ã ã®æ°ãããã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã§ãããé度ã¨ã¯ãã¹ãã©ãããã©ã¼ã ã®ãµãã¼ããåä¸ããã¨ä¸»å¼µãã¦ãã¾ãã
ãã¼ã¸ã§ã³ ããã¼ã¸ã£ã¼ã¨ã㦠Volta ãã¤ã³ã¹ãã¼ã«ããã«ã¯ããã¡ã¼ã¹ã ã¹ããã ã¬ã¤ãã® Windows ã¤ã³ã¹ãã¼ã« ã»ã¯ã·ã§ã³ã«ç§»åããã»ããã¢ããæé ã«å¾ã£ã¦ Windows ã¤ã³ã¹ãã¼ã©ã¼ããã¦ã³ãã¼ããã¦å®è¡ãã¾ãã
Volta ã使ç¨ã㦠Windows ã«è¤æ°ã®ãã¼ã¸ã§ã³ã® Node.js ãã¤ã³ã¹ãã¼ã«ããæ¹æ³ã®è©³ç´°ã«ã¤ãã¦ã¯ãVolta Docsãåç §ãã¦ãã ããã
Visual Studio Code ãã¤ã³ã¹ãã¼ã«ãã
Windows ã§ Node.js ã使ç¨ãã¦éçºããã«ã¯ãVisual Studio Code ãã¤ã³ã¹ãã¼ã«ãããã¨ã ãå§ããã¾ãã ãã«ãã«ã¤ãã¦ã¯ãVisual Studio Codeã®ãã¥ã¼ããªã¢ã«
代æ¿ã³ã¼ã ã¨ãã£ã¿ã¼
Visual Studio Code 以å¤ã®ã³ã¼ã ã¨ãã£ã¿ã¼ã¾ã㯠IDE ã使ç¨ããå ´åã¯ãNode.js éçºç°å¢ã«é©ãããªãã·ã§ã³ã次ã®ã¨ããã§ãã
Git ãã¤ã³ã¹ãã¼ã«ãã
ä»ã®ã¦ã¼ã¶ã¼ã¨å
±å使¥ãè¡ãå ´åãã¾ãã¯ããã¸ã§ã¯ãããªã¼ãã³ã½ã¼ã¹ ãµã¤ã (GitHub ãªã©) ã§ãã¹ãããå ´åãVS Code ã§ã¯ Gitã使ç¨ãã
git-scm Web ãµã¤ããã Git for Windows
ãã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã ã¤ã³ã¹ãã¼ã« ã¦ã£ã¶ã¼ããå«ã¾ãã¦ãããGit ã¤ã³ã¹ãã¼ã«ã®è¨å®ã«é¢ããä¸é£ã®è³ªåã表示ããã¾ãã ä½ãã夿´ããç¹å®ã®çç±ããªãéãããã¹ã¦ã®æ¢å®ã®è¨å®ã使ç¨ãããã¨ããå§ããã¾ãã
Git ã使ç¨ãããã¨ããªãå ´åã¯ãGitHub Guides ã使ç¨ãã¦ä½æ¥ãéå§ã§ãã¾ãã
.gitignore ãã¡ã¤ã« ã Node ããã¸ã§ã¯ãã«è¿½å ãããã¨ããå§ããã¾ãã Node.jsç¨ã® GitHub ã®æ¢å®ã® gitignore ãã³ãã¬ã¼ã
次ã«ç¤ºãã¾ãã
Windows Server ã§ã® Node.js
Windows ãµã¼ãã¼ã§ Node.js ã¢ããªããã¹ãããå¿
è¦ããã (ããã¾ããª) ç¶æ³ã«ããå ´åãæãä¸è¬çãªã·ããªãªã¯ããªãã¼ã¹ ãããã·ã使ç¨ãã¦
Windows developer