Change default global installation directory for node.js modules in Windows?

前端 未结 14 1575
遇见更好的自我
遇见更好的自我 2020-11-28 01:02

In my windows installation PATH includes C:\\Program Files\\nodejs, where executable node.exe is. I\'m able to launch node

14条回答
  •  遥遥无期
    2020-11-28 01:28

    trying to install global packages into C:\Program Files (x86)\nodejs\ gave me Run as Administrator issues, because npm was trying to install into
    C:\Program Files (x86)\nodejs\node_modules\

    to resolve this, change global install directory to C:\Users\{username}\AppData\Roaming\npm:

    in C:\Users\{username}\, create .npmrc file with contents:

    prefix = "C:\\Users\\{username}\\AppData\\Roaming\\npm"

    reference

    • npm install -g package installs global packages into prefix location
    • npmrc userconfig takes priority and overrides
    • npm config ls -l was showing prefix = "C:\\Program Files (x86)\\nodejs"

    environment
    nodejs x86 installer into C:\Program Files (x86)\nodejs\ on Windows 7 Ultimate N 64-bit SP1
    node --version : v0.10.28
    npm --version : 1.4.10

提交回复
热议问题