Edit:
It seems like new installers do not have this problem anymore, see this answer by Parag Meshram as my answer is likely obsolete now.
Original answer:
Follow these steps, closely:
- http://nodejs.org/download/ download the 64 bits version, 32 is for hipsters
- Install it anywhere you want, by default:
C:Program Files
odejs
- Control Panel -> System -> Advanced system settings -> Environment Variables
- Select
PATH
and choose to edit it.
If the PATH variable is empty
, change it to this: C:Users{YOUR USERNAME HERE}AppDataRoaming
pm;C:Program Files
odejs
If the PATH variable already contains C:Users{YOUR USERNAME HERE}AppDataRoaming
pm
, append the following right after: ;C:Program Files
odejs
If the PATH variable contains information, but nothing regarding npm, append this to the end of the PATH: ;C:Users{YOUR USERNAME HERE}AppDataRoaming
pm;C:Program Files
odejs
Now that the PATH variable is set correctly, you will still encounter errors. Manually go into the AppData directory and you will find that there is no npm directory inside Roaming. Manually create this directory.
Re-start the command prompt and npm will now work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…