Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"TypeError: Cannot read property 'get' of undefined" on each npm command

Tags:

node.js

npm

npm installation broke after setting a config parameter:

i.e. I set the cafile parameter of npm config, now every npm command returns this error:

Error: EISDIR: illegal operation on a directory, read
TypeError: Cannot read property 'get' of undefined
at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:228:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:266:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach ()
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at finalize (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:189:14)
at Conf.afterCARead (C:\Program Files\nodejs\node_modules\npm\lib\config\load-cafile.js:14:14)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205
if (npm.config.get('json')) {
^

it seems like I've broken the npm configuration by doing npm config set cafile ""

like image 594
Bertrand Boutillier Avatar asked Jan 22 '19 15:01

Bertrand Boutillier


2 Answers

Delete the file /Users/username/.npmrc.

I reinstalled node multiple times with and without nvm but this is the only thing that fixed the permissions issue.

like image 179
Edward Fancher Avatar answered Oct 06 '22 16:10

Edward Fancher


The solution is to edit the npm config file manualy. On Windows they are located here:

userconfig :

C:\Users\myuser\.npmrc

globalconfig :

C:\Users\myuser\AppData\Roaming\npm\etc\npmrc
like image 30
Bertrand Boutillier Avatar answered Oct 06 '22 16:10

Bertrand Boutillier