安装Angular CLI时出现错误400错误请求 [英] Getting error 400 Bad Request when installing Angular CLI

查看:57
本文介绍了安装Angular CLI时出现错误400错误请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用npm安装Angular CLI,因此我可以将Angular 4用于某些项目.但是,我收到了400 Bad Request错误.有人也遇到过这个问题并对此有解决方案吗?我已经尝试搜索一些与我的问题有关的信息,但是很不幸看到了这个问题.

I am in the middle of installing Angular CLI using npm so I could use Angular 4 for some projects. however, Im getting 400 Bad Request error. does somebody also encountered this problem and got a solution on this? I already tried searching some relating to my problem but unfortunate to see one.

命令:

npm config set proxy="myproxy.com:1234"
npm config set proxy-http="http://registry.npmjs.org/"
npm install -g @angular/cli

这是调试日志:

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 npm@5.6.0
3 info using node@v8.11.1
4 verbose npm-session a495756054a32527
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 400 https://registry.npmjs.org/@angular%2fcli 90ms
8 silly fetchPackageMetaData error for @angular/cli@latest 400 Bad Request: @angular/cli@latest
9 verbose stack Error: 400 Bad Request: @angular/cli@latest
9 verbose stack     at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
9 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
9 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
9 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
9 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
9 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
9 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
9 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
9 verbose stack     at Immediate.Async.drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
9 verbose stack     at runCallback (timers.js:794:20)
9 verbose stack     at tryOnImmediate (timers.js:752:5)
9 verbose stack     at processImmediate [as _immediateCallback] (timers.js:729:5)
10 verbose cwd C:\
11 verbose Windows_NT 6.1.7601
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
13 verbose node v8.11.1
14 verbose npm  v5.6.0
15 error code E400
16 error 400 Bad Request: @angular/cli@latest
17 verbose exit [ 1, true ]

好的,我现在通过此设置消除了400个错误:

ok guys, I just now remove that 400 bad error with this set up:

npm config set proxy="http://username:password@proxyserverpac:proxyport/"
npm config set https-proxy="http://username:password@proxyserverpac:proxyport/"
npm config set http-proxy="http://username:password@proxyserverpac:proxyport/"
npm config set registry="http://registry.npmjs.org/"

但是现在我遇到了这个错误:

but now I encounterred this error:

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   'info',
1 verbose cli   '@angular/cli' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose config Skipping project config: C:\Users\apamintuan/.npmrc. (matches userconfig)
5 silly mapToRegistry name @angular/cli
6 silly mapToRegistry scope (from package name) @angular
7 verbose mapToRegistry no registry URL found in name for scope @angular
8 silly mapToRegistry using default registry
9 silly mapToRegistry registry http://registry.npmjs.org/
10 silly mapToRegistry data { type: 'tag',
10 silly mapToRegistry   registry: true,
10 silly mapToRegistry   where: undefined,
10 silly mapToRegistry   raw: '@angular/cli',
10 silly mapToRegistry   name: '@angular/cli',
10 silly mapToRegistry   escapedName: '@angular%2fcli',
10 silly mapToRegistry   scope: '@angular',
10 silly mapToRegistry   rawSpec: '',
10 silly mapToRegistry   saveSpec: null,
10 silly mapToRegistry   fetchSpec: 'latest',
10 silly mapToRegistry   gitRange: undefined,
10 silly mapToRegistry   gitCommittish: undefined,
10 silly mapToRegistry   hosted: undefined }
11 silly mapToRegistry uri http://registry.npmjs.org/@angular%2fcli
12 verbose request uri http://registry.npmjs.org/@angular%2fcli
13 verbose request no auth needed
14 info attempt registry request try #1 at 12:46:50
15 verbose request id f486fd0b1ab9f374
16 http request GET http://registry.npmjs.org/@angular%2fcli
17 http 404 http://registry.npmjs.org/@angular%2fcli
18 verbose bad json <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
18 verbose bad json <html xmlns="http://www.w3.org/1999/xhtml">
18 verbose bad json <head>
18 verbose bad json <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
18 verbose bad json <title>404 - File or directory not found.</title>
18 verbose bad json <style type="text/css">
18 verbose bad json <!--
18 verbose bad json body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
18 verbose bad json fieldset{padding:0 15px 10px 15px;}
18 verbose bad json h1{font-size:2.4em;margin:0;color:#FFF;}
18 verbose bad json h2{font-size:1.7em;margin:0;color:#CC0000;}
18 verbose bad json h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
18 verbose bad json #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
18 verbose bad json background-color:#555555;}
18 verbose bad json #content{margin:0 0 0 2%;position:relative;}
18 verbose bad json .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
18 verbose bad json -->
18 verbose bad json </style>
18 verbose bad json </head>
18 verbose bad json <body>
18 verbose bad json <div id="header"><h1>Server Error</h1></div>
18 verbose bad json <div id="content">
18 verbose bad json  <div class="content-container"><fieldset>
18 verbose bad json   <h2>404 - File or directory not found.</h2>
18 verbose bad json   <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
18 verbose bad json  </fieldset></div>
18 verbose bad json </div>
18 verbose bad json </body>
18 verbose bad json </html>
19 error registry error parsing json
20 verbose headers { 'content-type': 'text/html',
20 verbose headers   server: 'Microsoft-IIS/7.5',
20 verbose headers   date: 'Tue, 17 Apr 2018 19:46:50 GMT',
20 verbose headers   'content-length': '1245' }
21 verbose stack SyntaxError: Unexpected token < in JSON at position 0
21 verbose stack <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
21 verbose stack <html xmlns="http://www.w3.org/1999/xhtml">
21 verbose stack <head>
21 verbose stack <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
21 verbose stack <title>404 - File or directory not found.</title>
21 verbose stack <style type="text/css">
21 verbose stack <!--
21 verbose stack body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
21 verbose stack fieldset{padding:0 15px 10px 15px;}
21 verbose stack h1{font-size:2.4em;margin:0;color:#FFF;}
21 verbose stack h2{font-size:1.7em;margin:0;color:#CC0000;}
21 verbose stack h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
21 verbose stack #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
21 verbose stack background-color:#555555;}
21 verbose stack #content{margin:0 0 0 2%;position:relative;}
21 verbose stack .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
21 verbose stack -->
21 verbose stack </style>
21 verbose stack </head>
21 verbose stack <body>
21 verbose stack <div id="header"><h1>Server Error</h1></div>
21 verbose stack <div id="content">
21 verbose stack  <div class="content-container"><fieldset>
21 verbose stack   <h2>404 - File or directory not found.</h2>
21 verbose stack   <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
21 verbose stack  </fieldset></div>
21 verbose stack </div>
21 verbose stack </body>
21 verbose stack </html>
21 verbose stack
21 verbose stack     at JSON.parse (<anonymous>)
21 verbose stack     at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:243:23)
21 verbose stack     at Request._callback (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:216:14)
21 verbose stack     at Request.self.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:186:22)
21 verbose stack     at emitTwo (events.js:126:13)
21 verbose stack     at Request.emit (events.js:214:7)
21 verbose stack     at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:1163:10)
21 verbose stack     at emitOne (events.js:116:13)
21 verbose stack     at Request.emit (events.js:211:7)
21 verbose stack     at IncomingMessage.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:1085:12)
21 verbose stack     at Object.onceWrapper (events.js:313:30)
21 verbose stack     at emitNone (events.js:111:20)
21 verbose stack     at IncomingMessage.emit (events.js:208:7)
21 verbose stack     at endReadableNT (_stream_readable.js:1064:12)
21 verbose stack     at _combinedTickCallback (internal/process/next_tick.js:138:11)
21 verbose stack     at process._tickCallback (internal/process/next_tick.js:180:9)
22 verbose cwd C:\Users\apamintuan
23 verbose Windows_NT 6.1.7601
24 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "info" "@angular/cli"
25 verbose node v8.11.1
26 verbose npm  v5.6.0
27 error Unexpected token < in JSON at position 0
27 error <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
27 error <html xmlns="http://www.w3.org/1999/xhtml">
27 error <head>
27 error <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
27 error <title>404 - File or directory not found.</title>
27 error <style type="text/css">
27 error <!--
27 error body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
27 error fieldset{padding:0 15px 10px 15px;}
27 error h1{font-size:2.4em;margin:0;color:#FFF;}
27 error h2{font-size:1.7em;margin:0;color:#CC0000;}
27 error h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
27 error #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
27 error background-color:#555555;}
27 error #content{margin:0 0 0 2%;position:relative;}
27 error .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
27 error -->
27 error </style>
27 error </head>
27 error <body>
27 error <div id="header"><h1>Server Error</h1></div>
27 error <div id="content">
27 error  <div class="content-container"><fieldset>
27 error   <h2>404 - File or directory not found.</h2>
27 error   <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
27 error  </fieldset></div>
27 error </div>
27 error </body>
27 error </html>
28 verbose exit [ 1, true ]

有人可以指导我如何克服这个问题吗?

could somebody guide me how I could overcome this problem?

现在,此问题已解决.

下面的答案/评论都没有解决我的问题.

none of the answers/comments below solved my problem.

不过,感谢您在这里的所有输入.我很感激.

however, thanks for all your inputs here. I appreciate it.

解决方案:我以为使用公司的代理服务器可以解决问题,但我没有听说提琴手是唯一的答案.我使用了它,然后将npm中的代理设置为" http://localhost:8888/",安装通过了

SOLUTION: I thought using the company's proxy server will do the trick but I didn't learned that fiddler is the only answer. I used it and set the proxy in npm to 'http://localhost:8888/' and the installation pushed through.

推荐答案

1 .open命令提示符

1.open Command promt

2 .运行命令"npm config edit"(打开一个文件)

2.run command "npm config edit"(open one file)

3 .已删除身份验证部分"strict-ssl = true和3-4行"并保存文件

3.removed auth section "strict-ssl=true and 3-4 line" and save file

然后再次安装角度cli

Then install again angular cli

这篇关于安装Angular CLI时出现错误400错误请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆