Cannot read property 'startsWith' of null in npm install

15,365

Solution 1

Finally after two days of hard working I found the answer. There was no proxy set in my configs in npm. Thats why when I tried npm config get proxy it was null. But there were two environmental variables set in my pc call http-proxy and https-proxy. But I don't know how they were set there. So I deleted those variables. Now my npm install works fine.

Solution 2

I faced this problem cause I manually remove the https-proxy and proxy settings in the .npmrc file. after I add it back everything get worked.

Share:
15,365

Related videos on Youtube

Achintha
Author by

Achintha

Updated on June 04, 2022

Comments

  • Achintha
    Achintha almost 2 years

    I searched this issue everywhere. But still couldn't find an answer. Most of answers say there's a problem with proxy. When I try to use npm install -g package-name an error is occurred.

    npm ERR! Cannot read property 'startsWith' of null
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-03-27T14_55_06_994Z-debug.log
    

    Here is the .log file

    0 info it worked if it ends with ok
    1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
    1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
    1 verbose cli   'install',
    1 verbose cli   '-g',
    1 verbose cli   '@angular/cli' ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose npm-session bd0a5d284789daec
    5 silly install loadCurrentTree
    6 silly install readGlobalPackageData
    7 silly fetchPackageMetaData error for @angular/cli@latest Cannot read property 'startsWith' of null
    8 verbose stack TypeError: Cannot read property 'startsWith' of null
    8 verbose stack     at getProxy (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\agent.js:164:25)
    8 verbose stack     at getAgent (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\agent.js:37:19)
    8 verbose stack     at remoteFetch (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\index.js:310:17)
    8 verbose stack     at opts.cacheManager.match.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\index.js:172:14)
    8 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
    8 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
    8 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
    8 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
    8 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
    8 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
    8 verbose stack     at Promise._resolveCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:432:57)
    8 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:524:17)
    8 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
    8 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
    8 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
    8 verbose stack     at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
    9 verbose cwd C:\
    10 verbose Windows_NT 10.0.16299
    11 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
    12 verbose node v8.10.0
    13 verbose npm  v5.6.0
    14 error Cannot read property 'startsWith' of null
    15 verbose exit [ 1, true ]
    

    Versions node - 8.10.0 npm - 5.6.0

    • Vikas
      Vikas about 6 years
      what is output you see when you execute this command npm get registry
    • Achintha
      Achintha about 6 years
      My output - registry.npmjs.org
    • Vikas
      Vikas about 6 years
      Have you tried the solution provided in this post
    • Achintha
      Achintha about 6 years
      I tried it. But it doesn't work for me. And also I'm runnig these commands on windows.
  • Raju Penumatsa
    Raju Penumatsa over 4 years
    Wow.. This helped me. Thank you.
  • Jamil Ahmed
    Jamil Ahmed almost 4 years
    can you gave me the path of .npmrc file
  • Jamil Ahmed
    Jamil Ahmed almost 4 years
    can you gave me the path of .npmrc file
  • Michael Goppelt
    Michael Goppelt over 2 years
    on windows: %USERPROFILE%\.npmrc