title: NPM behind proxy returning HTML
body: <p>I'm new to NPM and I think I've managed to finally get past the corporate proxy in place using these settings:</p>
  
  <pre><code>proxy = http://MyUsername:MyPassword@MyProxy:MyPort
  https-proxy = http://MyUsername:MyPassword@MyProxy:MyPort
  strict-ssl = false
  registry = http://registry.npmjs.org/
  </code></pre>
  
  <p>However, when I run an NPM command, such as <code>npm search</code> or <code>npm --proxy http://username:password@cacheaddress.com.br:80 install packagename</code>, I get the following error, which I don't understand:</p>
  
  <pre><code>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   'search' ]
  2 info using npm@1.4.3
  3 info using node@v0.10.26
  4 verbose node symlink C:\Program Files\nodejs\\node.exe
  5 warn Building the local index for the first time, please be patient
  6 verbose url raw /-/all
  7 verbose url resolving [ 'http://registry.npmjs.org/', './-/all' ]
  8 verbose url resolved http://registry.npmjs.org/-/all
  9 info trying registry request attempt 1 at 15:32:46
  10 http GET http://registry.npmjs.org/-/all
  11 http 407 http://registry.npmjs.org/-/all
  12 verbose bad json &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  12 verbose bad json &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
  12 verbose bad json &lt;head&gt;
  12 verbose bad json
  12 verbose bad json &lt;title&gt;Error Message&lt;/title&gt;
  12 verbose bad json &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  12 verbose bad json
  12 verbose bad json &lt;style&gt;
  12 verbose bad json body {
  12 verbose bad json
  12 verbose bad json     background:#e5eaf5 url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/bg.gif) top left repeat-x ;
  12 verbose bad json     margin:0px 0px 0px 0px;
  12 verbose bad json     font-family:Arial, Helvetica, sans-serif;
  12 verbose bad json     min-width:1000px;
  12 verbose bad json     font-size:12px;
  12 verbose bad json     color:#000000;
  12 verbose bad json     direction:ltr;
  12 verbose bad json     }
  12 verbose bad json img {border:none}
  12 verbose bad json
  12 verbose bad json
  12 verbose bad json     .main {
  12 verbose bad json         width:100%;
  12 verbose bad json         background:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/topright.gif) top right no-repeat;
  12 verbose bad json         min-width:1000px;
  12 verbose bad json         min-height:400px;
  12 verbose bad json         margin-left:auto;
  12 verbose bad json         margin-right:auto;
  12 verbose bad json         text-align:left;
  12 verbose bad json     }
  12 verbose bad json
  12 verbose bad json     .logo {float:left;  height:103px; }
  12 verbose bad json     .sidetext {float:right; width:182px; height:52px; background:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/sidetext.png) top left; border:1px solid #2a2e31; margin-right:20px; margin-top:20px; padding:4px; }
  12 verbose bad json     .sidetextNone {visibility:hidden; }
  12 verbose bad json
  12 verbose bad json     .whiteline {float:left; clear:both; font-size:20px; margin-left:47px; margin-top:17px; color:#ffffff; white-space:nowrap; }
  12 verbose bad json     .bold {font-weight:bold;}
  12 verbose bad json
  12 verbose bad json     .maintext {float:left; margin-top:20px; clear:both; color:#000; margin-left:47px;}
  12 verbose bad json
  12 verbose bad json     .color1 {color:#677183;}
  12 verbose bad json
  12 verbose bad json     ul {margin-top:0; padding-left:15px; padding-top:5px; padding-bottom:5px;}
  12 verbose bad json
  12 verbose bad json     ul li {list-style-image:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/bullet.gif)}
  12 verbose bad json     A {
  12 verbose bad json     FONT-WEIGHT: bold; COLOR: #005a80;
  12 verbose bad json }
  12 verbose bad json A:hover {
  12 verbose bad json     FONT-WEIGHT: bold;COLOR: #0d3372;
  12 verbose bad json }
  12 verbose bad json &lt;/style&gt;
  12 verbose bad json
  12 verbose bad json &lt;/head&gt;
  12 verbose bad json &lt;body&gt;
  12 verbose bad json     &lt;div class="main"&gt;
  12 verbose bad json         &lt;div class="logo"&gt;&lt;img src="/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/logo.png" alt="ForeFront" /&gt;&lt;/div&gt;
  12 verbose bad json         &lt;div class="whiteline"&gt;&lt;td id=L_default_2&gt;&lt;span class="bold"&gt;Network Access Message:&lt;/span&gt; The page cannot be displayed &lt;/td&gt;&lt;/div&gt;
  12 verbose bad json     &lt;div class="maintext"&gt;
  12 verbose bad json     &lt;td id=L_default_3&gt;&lt;span class="bold color1"&gt;Explanation:&lt;/span&gt; There is a problem with the page you are trying to reach and it cannot be displayed. &lt;/td&gt;&lt;br /&gt;
  12 verbose bad json &lt;br /&gt;
  12 verbose bad json
  12 verbose bad json &lt;td id=L_default_5&gt;&lt;span class="bold color1"&gt;Try the following:&lt;/span&gt;&lt;/td&gt;&lt;br /&gt;
  12 verbose bad json
  12 verbose bad json &lt;ul&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_6&gt;&lt;span class="bold"&gt;Refresh page:&lt;/span&gt; Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion.&lt;/td&gt;&lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_7&gt;&lt;span class="bold"&gt;Check spelling:&lt;/span&gt; Check that you typed the Web page address correctly. The address may have been mistyped.&lt;/td&gt;&lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_8&gt;&lt;span class="bold"&gt;Access from a link:&lt;/span&gt; If there is a link to the page you are looking for, try accessing the page from that link.&lt;/td&gt;&lt;/li&gt;
  12 verbose bad json &lt;/ul&gt;
  12 verbose bad json &lt;br /&gt;
  12 verbose bad json
  12 verbose bad json &lt;td id=L_default_9&gt;&lt;span&gt;If you are still not able to view the requested page, try contacting your administrator or Helpdesk.&lt;/span&gt; &lt;/td&gt;&lt;br /&gt;
  12 verbose bad json
  12 verbose bad json &lt;br /&gt;
  12 verbose bad json &lt;td id=L_default_10&gt;&lt;span class="bold color1"&gt;Technical Information (for support personnel)&lt;/span&gt;&lt;/td&gt;&lt;br /&gt;
  12 verbose bad json &lt;ul&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_11&gt;&lt;span class="bold"&gt;Error Code:&lt;/span&gt;&lt;/td&gt; 407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209).&lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_12&gt;&lt;span class="bold"&gt;IP Address:&lt;/span&gt;&lt;/td&gt; 185.31.17.162&lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_13&gt;&lt;span class="bold"&gt;Date:&lt;/span&gt;&lt;/td&gt; 2014/03/11 01:32:47 PM [GMT]&lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_14&gt;&lt;span class="bold"&gt;Server:&lt;/span&gt;&lt;/td&gt; OBTMG01.(MyCompany).local &lt;/li&gt;
  12 verbose bad json &lt;li&gt;&lt;td id=L_default_15&gt;&lt;span class="bold"&gt;Source:&lt;/span&gt;&lt;/td&gt; proxy  &lt;/li&gt;
  12 verbose bad json &lt;/ul&gt;
  12 verbose bad json     &lt;/div&gt;
  12 verbose bad json &lt;/div&gt;
  12 verbose bad json &lt;/body&gt;
  12 verbose bad json &lt;/html&gt;
  13 error registry error parsing json
  14 error SyntaxError: Unexpected token
  14 error &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  14 error &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
  14 error &lt;head&gt;
  14 error
  14 error &lt;title&gt;Error Message&lt;/title&gt;
  14 error &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
  14 error
  14 error &lt;style&gt;
  14 error body {
  14 error
  14 error    background:#e5eaf5 url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/bg.gif) top left repeat-x ;
  14 error    margin:0px 0px 0px 0px;
  14 error    font-family:Arial, Helvetica, sans-serif;
  14 error    min-width:1000px;
  14 error    font-size:12px;
  14 error    color:#000000;
  14 error    direction:ltr;
  14 error    }
  14 error img {border:none}
  14 error
  14 error
  14 error    .main {
  14 error        width:100%;
  14 error        background:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/topright.gif) top right no-repeat;
  14 error        min-width:1000px;
  14 error        min-height:400px;
  14 error        margin-left:auto;
  14 error        margin-right:auto;
  14 error        text-align:left;
  14 error    }
  14 error
  14 error    .logo {float:left;  height:103px; }
  14 error    .sidetext {float:right; width:182px; height:52px; background:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/sidetext.png) top left; border:1px solid #2a2e31; margin-right:20px; margin-top:20px; padding:4px; }
  14 error    .sidetextNone {visibility:hidden; }
  14 error
  14 error    .whiteline {float:left; clear:both; font-size:20px; margin-left:47px; margin-top:17px; color:#ffffff; white-space:nowrap; }
  14 error    .bold {font-weight:bold;}
  14 error
  14 error    .maintext {float:left; margin-top:20px; clear:both; color:#000; margin-left:47px;}
  14 error
  14 error    .color1 {color:#677183;}
  14 error
  14 error    ul {margin-top:0; padding-left:15px; padding-top:5px; padding-bottom:5px;}
  14 error
  14 error    ul li {list-style-image:url(/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/bullet.gif)}
  14 error    A {
  14 error     FONT-WEIGHT: bold; COLOR: #005a80;
  14 error }
  14 error A:hover {
  14 error     FONT-WEIGHT: bold;COLOR: #0d3372;
  14 error }
  14 error &lt;/style&gt;
  14 error
  14 error &lt;/head&gt;
  14 error &lt;body&gt;
  14 error    &lt;div class="main"&gt;
  14 error         &lt;div class="logo"&gt;&lt;img src="/Wbo-BC742A09-E6FA-4945-A21A-856A1F5CED22/logo.png" alt="ForeFront" /&gt;&lt;/div&gt;
  14 error         &lt;div class="whiteline"&gt;&lt;td id=L_default_2&gt;&lt;span class="bold"&gt;Network Access Message:&lt;/span&gt; The page cannot be displayed &lt;/td&gt;&lt;/div&gt;
  14 error     &lt;div class="maintext"&gt;
  14 error     &lt;td id=L_default_3&gt;&lt;span class="bold color1"&gt;Explanation:&lt;/span&gt; There is a problem with the page you are trying to reach and it cannot be displayed. &lt;/td&gt;&lt;br /&gt;
  14 error &lt;br /&gt;
  14 error
  14 error &lt;td id=L_default_5&gt;&lt;span class="bold color1"&gt;Try the following:&lt;/span&gt;&lt;/td&gt;&lt;br /&gt;
  14 error
  14 error &lt;ul&gt;
  14 error &lt;li&gt;&lt;td id=L_default_6&gt;&lt;span class="bold"&gt;Refresh page:&lt;/span&gt; Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion.&lt;/td&gt;&lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_7&gt;&lt;span class="bold"&gt;Check spelling:&lt;/span&gt; Check that you typed the Web page address correctly. The address may have been mistyped.&lt;/td&gt;&lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_8&gt;&lt;span class="bold"&gt;Access from a link:&lt;/span&gt; If there is a link to the page you are looking for, try accessing the page from that link.&lt;/td&gt;&lt;/li&gt;
  14 error &lt;/ul&gt;
  14 error &lt;br /&gt;
  14 error
  14 error &lt;td id=L_default_9&gt;&lt;span&gt;If you are still not able to view the requested page, try contacting your administrator or Helpdesk.&lt;/span&gt; &lt;/td&gt;&lt;br /&gt;
  14 error
  14 error &lt;br /&gt;
  14 error &lt;td id=L_default_10&gt;&lt;span class="bold color1"&gt;Technical Information (for support personnel)&lt;/span&gt;&lt;/td&gt;&lt;br /&gt;
  14 error &lt;ul&gt;
  14 error &lt;li&gt;&lt;td id=L_default_11&gt;&lt;span class="bold"&gt;Error Code:&lt;/span&gt;&lt;/td&gt; 407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209).&lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_12&gt;&lt;span class="bold"&gt;IP Address:&lt;/span&gt;&lt;/td&gt; 185.31.17.162&lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_13&gt;&lt;span class="bold"&gt;Date:&lt;/span&gt;&lt;/td&gt; 2014/03/11 01:32:47 PM [GMT]&lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_14&gt;&lt;span class="bold"&gt;Server:&lt;/span&gt;&lt;/td&gt; OBTMG01.(MyCompany).local &lt;/li&gt;
  14 error &lt;li&gt;&lt;td id=L_default_15&gt;&lt;span class="bold"&gt;Source:&lt;/span&gt;&lt;/td&gt; proxy  &lt;/li&gt;
  14 error &lt;/ul&gt;
  14 error     &lt;/div&gt;
  14 error &lt;/div&gt;
  14 error &lt;/body&gt;
  14 error &lt;/html&gt;
  14 error
  14 error     at Object.parse (native)
  14 error     at RegClient.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:203:23)
  14 error     at Request.self.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:123:22)
  14 error     at Request.EventEmitter.emit (events.js:98:17)
  14 error     at Request.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:893:14)
  14 error     at Request.EventEmitter.emit (events.js:117:20)
  14 error     at IncomingMessage.&lt;anonymous&gt; (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:844:12)
  14 error     at IncomingMessage.EventEmitter.emit (events.js:117:20)
  14 error     at _stream_readable.js:920:16
  14 error     at process._tickCallback (node.js:415:13)
  15 error If you need help, you may report this *entire* log,
  15 error including the npm and node versions, at:
  15 error     &lt;http://github.com/npm/npm/issues&gt;
  16 error System Windows_NT 6.1.7601
  17 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "search"
  18 error cwd C:\Users\(MyUsername)
  19 error node -v v0.10.26
  20 error npm -v 1.4.3
  21 error type unexpected_token
  22 verbose exit [ 1, true ]
  </code></pre>