nodejs npm global config missing on windows

后端 未结 7 807
囚心锁ツ
囚心锁ツ 2020-12-12 19:27

I can\'t find at all where npm has its global settings stored.

npm config get userconfig

C:\\Users\\Jack\\.npmrc

npm config get glo

7条回答
  •  心在旅途
    2020-12-12 19:51

    There is a problem with upgrading npm under Windows. The inital install done as part of the nodejs install using an msi package will create an npmrc file:

    C:\Program Files\nodejs\node_modules\npm\npmrc

    when you update npm using:

    npm install -g npm@latest

    it will install the new version in:

    C:\Users\Jack\AppData\Roaming\npm

    assuming that your name is Jack, which is %APPDATA%\npm.

    The new install does not include an npmrc file and without it the global root directory will be based on where node was run from, hence it is C:\Program Files\nodejs\node_modules

    You can check this by running:

    npm root -g

    This will not work as npm does not have permission to write into the "Program Files" directory. You need to copy the npmrc file from the original install into the new install. By default the file only has the line below:

    prefix=${APPDATA}\npm

提交回复
热议问题