NPM配置文件在哪里?

时间:2019-10-09 20:32:11

标签: npm

我用npm edit config编辑了npm配置文件。我在其中犯了语法错误,并保存了文件。现在,无论我对npm尝试什么,它都会对此有所抱怨。我知道语法是什么,我想对其进行修复,但在任何地方都找不到该文件。

C:\Users\Arthur>npm
Error: Failed parsing JSON config key cache: "C:\Users\Le Roi Arthur\AppData\Roaming\npm-cache"
    at parseField (D:\nodejs\node_modules\npm\lib\config\core.js:376:13)
    at D:\nodejs\node_modules\npm\lib\config\core.js:330:24
    at Array.forEach (<anonymous>)
    at Conf.add (D:\nodejs\node_modules\npm\lib\config\core.js:328:23)
    at ConfigChain.addString (D:\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
    at Conf.<anonymous> (D:\nodejs\node_modules\npm\lib\config\core.js:316:10)
    at D:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:90:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
TypeError: Cannot read property 'loaded' of undefined
    at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
    at errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at D:\nodejs\node_modules\npm\bin\npm-cli.js:77:20
    at cb (D:\nodejs\node_modules\npm\lib\npm.js:225:22)
    at D:\nodejs\node_modules\npm\lib\npm.js:263:24
    at D:\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at Conf.<anonymous> (D:\nodejs\node_modules\npm\lib\config\core.js:82:13)
    at Conf.f (D:\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at Object.onceWrapper (events.js:286:20)
D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
    at process.errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:198:13)
    at process._fatalException (internal/bootstrap/node.js:496:27)
Error: Failed parsing JSON config key cache: "C:\Users\Le Roi Arthur\AppData\Roaming\npm-cache"
    at parseField (D:\nodejs\node_modules\npm\lib\config\core.js:376:13)
    at D:\nodejs\node_modules\npm\lib\config\core.js:330:24
    at Array.forEach (<anonymous>)
    at Conf.add (D:\nodejs\node_modules\npm\lib\config\core.js:328:23)
    at ConfigChain.addString (D:\nodejs\node_modules\npm\node_modules\config-chain\index.js:244:8)
    at Conf.<anonymous> (D:\nodejs\node_modules\npm\lib\config\core.js:316:10)
    at D:\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:90:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
TypeError: Cannot read property 'loaded' of undefined
    at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
    at errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at D:\nodejs\node_modules\npm\bin\npm-cli.js:77:20
    at cb (D:\nodejs\node_modules\npm\lib\npm.js:225:22)
    at D:\nodejs\node_modules\npm\lib\npm.js:263:24
    at D:\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at Conf.<anonymous> (D:\nodejs\node_modules\npm\lib\config\core.js:82:13)
    at Conf.f (D:\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at Object.onceWrapper (events.js:286:20)
D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
    at process.errorHandler (D:\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:198:13)
    at process._fatalException (internal/bootstrap/node.js:496:27)

卸载并重新安装nodeJS不能解决该问题,该文件存储在缓存中的某个位置。将我的手放在那个文件上有多困难,这真令人沮丧。

我在哪里可以找到npm配置文件?

1 个答案:

答案 0 :(得分:5)

您需要编辑npmrc文件,看看documentation,它将帮助您找到合适的文件。

  

四个相关文件是:

     
      
  • 每个项目的配置文件:/path/to/my/project/.npmrc
  •   
  • 每用户配置文件:〜/ .npmrc
  •   
  • 全局配置文件:$ PREFIX / npmrc
  •   
  • 内置的npm配置文件:/ path / to / npm / npmrc
  •